ObjectiveFlickr - how to call getSizes on a photo ID not known until the response?

Posted by Jonathan Cohen on Stack Overflow See other posts from Stack Overflow or by Jonathan Cohen
Published on 2010-04-15T23:12:30Z Indexed on 2010/04/16 14:03 UTC
Read the original article Hit count: 272

Filed under:
|
|

Hi guys,

I'm building a free music instrument iPhone app with the Flickr API and ObjectiveFlickr.A random photo from the interestingness list is displayed in the background, but I can't center it without knowing its size. (so I can reset the UIWebView frame)

I've been researching this for awhile, and if the answer is super easy, please have some mercy on a noob - it's my first time playing with a web service API. =)

Since I don't know the photo ID until after I receive the response from the interestingness feed, how would I call flickr.photo.getSizes on the response? This is what I have so far:

- (void)flickrAPIRequest:(OFFlickrAPIRequest *)inRequest didCompleteWithResponse:(NSDictionary *)inResponseDictionary{
 int randomResponse = arc4random() % 49;
 photoDict = [[inResponseDictionary valueForKeyPath:@"photos.photo"] objectAtIndex:randomResponse];

 NSString *photoID = [photoDict valueForKeyPath:@"id"];

 NSLog(@"%@",photoID);

 NSURL *photoURL = [flickrContext photoSourceURLFromDictionary:photoDict size:OFFlickrMediumSize];
 NSString *htmlSource = [NSString stringWithFormat:
       @"<html>"
       @"<head>"
       @"  <style>body { margin: 0; padding: 0; } </style>"
       @"</head>"
       @"<body>"
       @"<img src=\"%@\" />"
       @"</body>"
       @"</html>"
       , photoURL];

 [webView loadHTMLString:htmlSource baseURL:nil];
}

© Stack Overflow or respective owner

Related posts about iphone

Related posts about flickr