Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>If anyone else is having the same issue, heres the link: <a href="https://github.com/stig/json-framework/" rel="nofollow">https://github.com/stig/json-framework/</a> scroll down to <strong>Project renamed to SBJson</strong> </p> <p>Also, here is the code for getting all the data before your app uses it. Note the delegate method 'did receive data' as it appends the mutable data object with the downloaded data. </p> <p>I JUST USED MR GANDOS searchCoodinatesMETHOD AS IT IS AS IT WORKS WELL</p> <pre><code>- (void) searchCoordinatesForAddress:(NSString *)inAddress { //Build the string to Query Google Maps. NSMutableString *urlString = [NSMutableString stringWithFormat:@"http://maps.googleapis.com/maps/api/geocode/json?address=%@&amp;sensor=false",inAddress]; //Replace Spaces with a '+' character. [urlString setString:[urlString stringByReplacingOccurrencesOfString:@" " withString:@"+"]]; //Create NSURL string from a formate URL string. NSURL *url = [NSURL URLWithString:urlString]; //Setup and start an async download. //Note that we should test for reachability!. NSURLRequest *request = [[NSURLRequest alloc] initWithURL:url]; NSURLConnection *connection = [[NSURLConnection alloc] initWithRequest:request delegate:self]; [connection release]; [request release]; } </code></pre> <p>// STEP ONE // THIS ONE IS IMPORTANT AS IT CREATES THE MUTABLE DATA OBJECT AS SOON AS A RESPONSE IS RECEIVED</p> <pre><code>-(void)connection:(NSURLConnection*)connection didReceiveResponse:(NSURLResponse*)response { if (receivedGeoData) { [receivedGeoData release]; receivedGeoData = nil; receivedGeoData = [[NSMutableData alloc] init]; } else { receivedGeoData = [[NSMutableData alloc] init]; } } </code></pre> <p>/// STEP TWO // THIS ONE IS IMPORTANT AS IT APPENDS THE DATA OBJECT WITH THE DATA</p> <pre><code>- (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data { [receivedGeoData appendData:data]; } </code></pre> <p>// STEP THREE...... // NOW THAT YOU HAVE ALL THE DATA MAKE USE OF IT</p> <pre><code>- (void)connectionDidFinishLoading:(NSURLConnection *)connection { NSString *jsonResult = [[NSString alloc] initWithData:receivedGeoData encoding:NSUTF8StringEncoding]; NSError *theError = NULL; dictionary = [NSMutableDictionary dictionaryWithJSONString:jsonResult error:&amp;theError]; NSLog(@"%@",dictionary); int numberOfSites = [[dictionary objectForKey:@"results"] count]; NSLog(@"count is %d ",numberOfSites); } -(void)connection:(NSURLConnection*)connection didFailWithError:(NSError*)error { // Handle the error properly } </code></pre>
 

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