title: Returning an image into imageView from Google Places Photo JSON
body: <p>I'm looking to get the photos from the Google places API, and have them store into a URL or Image to be displayed to the user in a seperate view controller.</p>
  
  <p>It appears the photo json returns this for each location:</p>
  
  <pre><code>    photos =  (
                  {
                     height = 466;
                     "html_attributions" = ();
                     "photo_reference" = "CnRnAAAAgBUy_mqt9WglYJvS2v8XBfw5ER1U8Wn7DWvfoWI4P78w8_ZAsLQeFSYescNYE1NVgkV50jJE7SYBxdZuOmGP4jWGyCLobCd2nyEDbeB9lg1JU7KYV0o57i-OQTROIwj9ZwzWG03aUOypMjA_7fXD8BIQqbC5J0daROt_LqztWmz-xhoU20meJb50VyAE-zqkp9Jzu1Fegfs";
                     width = 695;
                  }
               );
  </code></pre>
  
  <p>And according to Google Places Photo docs all it says:</p>
  
  <p><a href="https://developers.google.com/places/documentation/photos" rel="nofollow">https://developers.google.com/places/documentation/photos</a></p>
  
  <p>Cannot find an example to be able to take this from json, and store it like I am strings since the url isn't a direct link to an image or anything.</p>
  
  <p>EDIT: Getting error </p>
  
  <pre><code>[__NSCFArray objectForKey:]: unrecognized selector sent to instance 0x13258510
   *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFArray objectForKey:]: unrecognized selector sent to instance 0x13258510'
  </code></pre>
  
  <p>Updated Code:</p>
  
  <pre><code>-(void)plotPositions:(NSArray *)data {
  
      for (id&lt;MKAnnotation&gt; annotation in _mapView.annotations) {
          if ([annotation isKindOfClass:[MapPoint class]]) {
              [_mapView removeAnnotation:annotation];
          }
      }
      //  Loop through the array of places returned from the Google API.
      for (int i=0; i&lt;[data count]; i++) {
  
          NSDictionary* place = [data objectAtIndex:i];
  
          NSDictionary *geo = [place objectForKey:@"geometry"];
  
          NSDictionary *loc = [geo objectForKey:@"location"];
  
          // Getting Photo Reference Details - ADDED NOW RECIEVING ERROR?
          NSDictionary *photoDict = [place objectForKey:@"photos"];
          NSString *photoRef = [photoDict objectForKey:@"photo_reference"];
  
           NSString *url = [NSString stringWithFormat:@"https://maps.googleapis.com/maps/api/place/photo?photoreference=%@&amp;key=%@&amp;sensor=false&amp;maxwidth=320", photoRef, kGOOGLE_API_KEY];
  
          NSLog(@"TESTING: %@", url);
  
  
          NSString *name=[place objectForKey:@"name"];
          NSString *vicinity=[place objectForKey:@"vicinity"];
  
  
          CLLocationCoordinate2D placeCoord;
          placeCoord.latitude=[[loc objectForKey:@"lat"] doubleValue];
          placeCoord.longitude=[[loc objectForKey:@"lng"] doubleValue];
  
          MapPoint *placeObject = [[MapPoint alloc] initWithName:name address:vicinity rating:rating coordinate:placeCoord];
  
          [_mapView addAnnotation:placeObject];
      }
  }
  </code></pre>