Solved

iPhone - parse json returned from google api

Posted on 2011-09-19
1
828 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

In this article I'm going to cover the basics and usages of NSInvocation. What is NSInvocation? Apple Developer Reference describes NSInvocation this way: An NSInvocation is an Objective-C message rendered static, that is, it is an action tur…
Short answer to this question: there is no effective WiFi manager in iOS devices as seen in Windows WiFi or Macbook OSx WiFi management, but this article will try and provide some amicable solutions to better suite your needs.
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.
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

628 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