1

I've setup the ObjectiveFlickr according to the documentations, and i've wrote this block in a button action

OFFlickrAPIContext *context = [[OFFlickrAPIContext alloc] initWithAPIKey:FLICKR_API_KEY sharedSecret:FLICKR_API_SHARED_SECRET];
OFFlickrAPIRequest *request = [[OFFlickrAPIRequest alloc] initWithAPIContext:context];
[request setDelegate:self];
[request fetchOAuthRequestTokenWithCallbackURL: [NSURL URLWithString:FLICKR_CALLBACK]];

but when i click on the button nothings happens

- (void)flickrAPIRequest:(OFFlickrAPIRequest *)inRequest didObtainOAuthRequestToken:(NSString *)inRequestToken secret:(NSString *)inSecret

does not get called, pretty much nothing happens

Charlie Wu
  • 7,657
  • 5
  • 33
  • 40

1 Answers1

1

(Yes, old question, hopefully this will help someone else)

Make sure that when you allocate your OFFlickrRequest object, it is retained somehow, such as by making it a property of the class and not a local variable. If you only store it within the current scope, ARC will delete it when you exit the scope so when the asynchronous fetchOAuthRequest call returns it will have no reference to what delegate to call.

i.e. this is wrong:

- (void)doDBLogin:(UIButton*)button {
    OFFlickrAPIRequest *flickrRequest = [[OFFlickrAPIRequest alloc] initWithAPIContext:_flickrContext];
    [flickrRequest setDelegate:self];
    [flickrRequest fetchOAuthRequestTokenWithCallbackURL:[NSURL URLWithString:MY_AUTH_URL]];

    // At this point, flickrRequest is about to be destroyed.
}
Jim Keir
  • 546
  • 5
  • 9