Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

iPhone - parse json returned from google api

Posted on 2011-09-19
1
Medium Priority
?
846 Views
Last Modified: 2012-05-12
I am new to iOS programming and the JSON library. I am attempting to get the value of the status as returned from google (shown below)


        NSDictionary *dictionary = [responseString JSONValue];
        NSString *status = [[dictionary objectForKey:@"status"] stringValue];

Here is what I thought would work but it crashes. I'm getting very confused on the proper use of the JSON library.


{
   "results" : [
      {
         "address_components" : [
            {
               "long_name" : "Walton",
               "short_name" : "Walton",
               "types" : [ "locality", "political" ]
            },
            {
               "long_name" : "Boone",
               "short_name" : "Boone",
               "types" : [ "administrative_area_level_2", "political" ]
            },
            {
               "long_name" : "Kentucky",
               "short_name" : "KY",
               "types" : [ "administrative_area_level_1", "political" ]
            },
            {
               "long_name" : "United States",
               "short_name" : "US",
               "types" : [ "country", "political" ]
            }
         ],
         "formatted_address" : "Walton, KY, USA",
         "geometry" : {
            "bounds" : {
               "northeast" : {
                  "lat" : 38.88926600000001,
                  "lng" : -84.58743790
               },
               "southwest" : {
                  "lat" : 38.84176990,
                  "lng" : -84.6405750
               }
            },
            "location" : {
               "lat" : 38.87561940000001,
               "lng" : -84.61022129999999
            },
            "location_type" : "APPROXIMATE",
            "viewport" : {
               "northeast" : {
                  "lat" : 38.89299050,
                  "lng" : -84.57820650000001
               },
               "southwest" : {
                  "lat" : 38.85824410,
                  "lng" : -84.64223609999999
               }
            }
         },
         "types" : [ "locality", "political" ]
      }
   ],
   "status" : "OK"
}
0
Comment
Question by:lachmann
1 Comment
 
LVL 13

Accepted Solution

by:
SpeedyApocalypse earned 2000 total points
ID: 36566645
What is the crash message?
0

Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When Apple released Swift last year, the aim was to introduce a new programming language for Cocoa and Cocoa Touch that was fast, easy and effective, like the name connotes. Apple succeeded. Swift is designed to couple with Objective-C program…
The release of the iPhone 6 and the iPhone 6 Plus was extremely successful for Apple. However when iOS 8.1 was introduced, many iPhone users complained of quick battery drainage. Without even knowing, you may be unnecessarily using up your battery p…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
Suggested Courses

926 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question