0

So basically I'm trying to learn more about iOS development and APIs, so I'm building an iOS app that allows people to search a zipcode and then it will return all of the restaurants currently open within a certain radius. I got the Google Maps API setup properly, but I'm running into issues with how to get that info.

I looked at the Google Places API and it looks like I will be able to get a JSON result and then I can just look for the "open_now" : true key/value. Currently, there is a Google Places API for Android and Javascript, but the iOS one is still in beta. Can I use this Javascript API to pass the JSON into my Obj-C code for iOS Development? Thanks!

prisonbreakx
  • 63
  • 1
  • 1
  • 4
  • Wait, are you looking for Objective-C or javascript? That's confusing. Perhaps this is what you are looking for: https://code.google.com/p/gdata-objectivec-client/ – briosheje Apr 27 '15 at 18:34

3 Answers3

1

To use the Google Places API make a simple POST request with AFNetworking

For example:

AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
NSDictionary *parameters = @{@"key": @"YOUR_KEY", @"location": @"YOUR_LOCATION"};
[manager POST:@"https://maps.googleapis.com/maps/api/place/nearbysearch/" parameters:parameters success:^(AFHTTPRequestOperation *operation, id   responseObject) {
    NSLog(@"JSON: %@", responseObject);
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
    NSLog(@"Error: %@", error);
}];

Now with the json "responseObject" you can do anything

Try to parse it with json-framework

pekpon
  • 761
  • 1
  • 10
  • 24
0

You're probably looking for info on how to parse JSON with Objective-C: How do I parse JSON with Objective-C?

In a nutshell, use the NSJSONSerialization class to convert JSON to Foundation objects and Foundation objects to JSON.

Community
  • 1
  • 1
TomSlick
  • 717
  • 5
  • 21
0

You don't need the javascript API for that task. The Google Places API belongs to the Google Maps Web service suite, so you just need to make a http request in order to retreive the data.

Making http requests on obj-c is addressed in here and you'll just need to parse the JSON response.

Community
  • 1
  • 1
dadrimon2
  • 33
  • 1
  • 3