Tell me more ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

I would like to retrieve JSON data from a website, but the user would be able to enter a URL. I tried using

NSURL * url = [NSURL URLWithString:getDataURL];

and to define getDataURL I used

#define getDataURL @"http://..." 

This works but I can't change the URL. Is their a way to do what I need ?

share|improve this question
What kind of application are you creating? Is it for iOS or OS X? You have to provide more information. I assume you have to create a text field where the user can type the URL and then read the value of the field at some point. – Felix Kling Jul 20 at 13:02
add comment (requires an account with 50 reputation)

closed as unclear what you're asking by Dirk, rptwsthi, Josh Caswell, Yotam Omer, ldav1s Jul 20 at 21:49

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking.If this question can be reworded to fit the rules in the help center, please edit the question.

1 Answer

up vote 0 down vote accepted

You're using a string constant, but you can get the string from anywhere. If you want the user to enter the string, you can use a text field in your user interface and let the user type the URL there. Then you'll get the URL:

NSString* getDataUrl = theTextField.text;
share|improve this answer
to save the content of the textfield I used a .plist file. then, I read that file and retrieve the url in a variable name "array" do I did NSString* getDataUrl = array; and then NSURL * url = [NSURL URLWithString:getDataUrl]; but then when I run I get a "signal sigabrt" in here : "citiesArray = [[NSMutableArray alloc]init]; if([json isKindOfClass:[NSArray class]]){ ...} " Thanks for your help ! – JRock Jul 20 at 13:43
That sounds like an entirely different question from the one here. You should really start a separate post and not try to address it in comments. More information will help, but before you post dig in and see if you can't solve the problem yourself. – Caleb Jul 20 at 14:04
add comment (requires an account with 50 reputation)

Not the answer you're looking for? Browse other questions tagged or ask your own question.