This example takes a simple view controller, calls the googlemaps api, and parses the returning JSON results.

The network call

NSURLConnection is the object that handles the HTTP request. You basically define the URL you are connecting to, implement the required delegates, and then get notified when the request is complete in the connectionDidFinishLoading method.

Parsing the JSON

NSJSONSerialization seems to currently be the best way to take your URL response and convert it into an iOS JSON object.

With this object you can then parse the response, looking at the keys and values, and then manually determine which elements you want to extract.

The code

Putting all that together, you get something that looks like this:


#import "spike1ViewController.h"

@interface spike1ViewController()
@property (nonatomic, strong) NSMutableData *responseData;

@implementation spike1ViewController

@synthesize responseData = _responseData;

- (void)viewDidLoad { 
    [super viewDidLoad]; 
    self.responseData = [NSMutableData data]; 
    NSURLRequest *request = [NSURLRequest requestWithURL:
                             [NSURL URLWithString:@",151.1957362&radius=500&types=food&name=harbour&sensor=false&key=AIzaSyAbgGH36jnyow0MbJNP4g6INkMXqgKFfHk"]];
    [[NSURLConnection alloc] initWithRequest:request delegate:self];
- (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response {
    [self.responseData setLength:0];

- (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data {        
    [self.responseData appendData:data]; 

- (void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error {    
    NSLog([NSString stringWithFormat:@"Connection failed: %@", [error description]]);

- (void)connectionDidFinishLoading:(NSURLConnection *)connection {
    NSLog(@"Succeeded! Received %d bytes of data",[self.responseData length]);
    // convert to JSON
    NSError *myError = nil;
    NSDictionary *res = [NSJSONSerialization JSONObjectWithData:self.responseData options:NSJSONReadingMutableLeaves error:&myError];
    // show all values
    for(id key in res) {
        id value = [res objectForKey:key];
        NSString *keyAsString = (NSString *)key;
        NSString *valueAsString = (NSString *)value;
        NSLog(@"key: %@", keyAsString);
        NSLog(@"value: %@", valueAsString);
    // extract specific value...
    NSArray *results = [res objectForKey:@"results"];

    for (NSDictionary *result in results) {
        NSString *icon = [result objectForKey:@"icon"];
        NSLog(@"icon: %@", icon);


- (void)viewDidUnload {
    [super viewDidUnload];


You can tell it’s working by looking at the output in the NSLogs. Should see something that looks like this: