Solved

iPhone - parse json returned from google api

Posted on 2011-09-19
1
820 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: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering 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

Ever wanted to watch videos in your computer from the bed without the need of standing up and shutting down the computer?  Is your computers operating system Windows XP, Windows Vista or Windows 7?  Do you own a iOS device? If all the answers were y…
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…
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.
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

752 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