2

I'm still new to programming so any help would be greatly appreciated.

I'm trying to use the Yelp api in a new app I'm making. I integrated the api using the example project provided by Yelp here: https://github.com/Yelp/yelp-api (v2/objective c). My question is how do I access the information that the sample program logs out. It saves it in an NSDictionary but I can't figure out how to access the info so I can for example display the business's phone number in a label in one of my view controllers.

Thanks

Matt
  • 57
  • 6

1 Answers1

0

You would access the keys and objects just as you would any other NSDictionary, for example in YPAPISample.m:

- (void)queryTopBusinessInfoForTerm:
          (NSString *)term location:
          (NSString *)location completionHandler:
          (void (^)(NSDictionary *topBusinessJSON, NSError *error))
          completionHandler {
  ...

  NSString *phoneNumber = [firstBusiness objectForKey:@"display_phone"];
  NSLog(@"PHONE NUMBER: %@",phoneNumber);

Output:

PHONE NUMBER: +1-415-777-1413

l'L'l
  • 44,951
  • 10
  • 95
  • 146