Solved

iPhone - parse json returned from google api

Posted on 2011-09-19
1
798 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 500 total points
ID: 36566645
What is the crash message?
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

The Basics of Storyboard Storyboards were first introduced to developers in the release of iOS 5. They save the developer the trouble of designing each screen’s interface in a different file. The storyboard allows you to see the conceptual mockup o…
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…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …
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.

707 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now