Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to retrieve json data from url
    primarykey
    data
    text
    <p>Basically I am trying to retrieve json data from a custom search engine and I am not successful(link is just a place holder cant show real link).I will post my objective c code and will show you my json code on the bottom. Basically I am trying to retrieve TermText from it, but I have not been successful. I basically rip this code from a bing tutorial.Any help would be appreciated.Right now, the code is giving me a console log nil.<br> .h</p> <pre><code> @interface ViewController : UIViewController{ NSString *jsonstring; } @property (nonatomic,retain)NSString *offValue; -(void) searchBing:(NSString *)text; -(void)getData:(NSData *) response; </code></pre> <p>.m</p> <pre><code> -(void)searchBing:(NSString *)text{ //MODIFY NSString *urlString=[NSString stringWithFormat:@"%@%@%@%@",@"http://api/text data.",text,@"&amp;sources=web&amp;web.offset=",offValue]; NSURL *url =[NSURL URLWithString:urlString]; NSData *data =[NSData dataWithContentsOfURL:url]; [self getData:data]; } -(void)getData:(NSData *)response{ NSError *error; NSMutableDictionary *json = [NSJSONSerialization JSONObjectWithData:response options:kNilOptions error:&amp;error]; NSLog(@"%@",json); } - (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view, typically from a nib. offValue =@"0"; [self searchBing:@"Term"]; } </code></pre> <p>Json</p> <pre><code> { "ReturnValue": [ { "Term": { "TermID": 1, "TermText": "sample string 2", "Description": "sample string 3" } }, { "Term": { "TermID": 1, "TermText": "sample string 2", "Description": "sample string 3" } }, { "Term": { "TermID": 1, "TermText": "sample string 2", "Description": "sample string 3" } } ], "ResultCode": 0, "ResultCodeName": 0, "ErrorMessage": "sample string 2" } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload