Solved

iPhone - parse json returned from google api

Posted on 2011-09-19
1
815 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

CocoaPods is the best way to manage library dependencies in iOS and OS X projects. By using cocoa pods there is no need of downloading the code from github and copying to your project. There are plenty of open source libraries now available with C…
     Intro      In this article, I will show you how to parse a JSON in Swift using an open source library called SwiftyJSON (https://github.com/SwiftyJSON/SwiftyJSON). If you haven't heard of a JSON before, it stands for JavaScript Object Notation…
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.
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

828 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