objectiveflickr
objectiveflickr copied to clipboard
delegate callback doesn't get called when call callAPIMethodWithGET
and if I manually set the shouldWaitUntilDone to YES before performing the http request, the callback can be called successfully.
if (requestURL) {
[HTTPRequest setContentType:nil];
+ [HTTPRequest setShouldWaitUntilDone:YES];
return [HTTPRequest performMethod:LFHTTPRequestGETMethod onURL:requestURL withData:nil];
}
return NO;
IOS 5.1 ARC enabled, link objectiveflickr as static library, this is how i use objectiveflickr. (most copied from the sample code)
the flickrAPIRequest callback doesn't get called.
- (RocoFlickrPhoto *) init {
flickrAPIContext = [[OFFlickrAPIContext alloc] initWithAPIKey:FLICKR_API_KEY sharedSecret:FLICKR_API_SHARED_SECRET];
flickrRequest = [[OFFlickrAPIRequest alloc] initWithAPIContext:flickrAPIContext];
[flickrRequest setDelegate:self];
return self;
}
- (void) flickrAPIRequest:(OFFlickrAPIRequest *)inRequest didCompleteWithResponse:(NSDictionary *)inResponseDictionary {
NSDictionary *photoDict = [[inResponseDictionary valueForKeyPath:@"photos.photo"] objectAtIndex:0];
NSString *title = [photoDict objectForKey:@"title"];
if (![title length]) {
title = @"No title";
}
NSURL *photoSourcePage = [flickrAPIContext photoWebPageURLFromDictionary:photoDict];
}
- (RocoPhoto *) getRecentPhoto {
if (![flickrRequest isRunning]) {
BOOL result = [flickrRequest callAPIMethodWithGET:@"flickr.photos.getRecent" arguments:[NSDictionary dictionaryWithObjectsAndKeys:@"1", @"per_page", nil]];
}
return nil;
}
seems a bug of Xcode.
not a bug of Xcode.
Have the same issue.
Thanks @MelvinTo for the + [HTTPRequest setShouldWaitUntilDone:YES];
, but it seems that this issue is present and should be resolved.
Do anyone have any thoughts on this?
Found a problem and a solution: a request object had been autoreleased before it received any response, so just own that request either by adding to an array or capturing it with a strong pointer and everything will be ok.
It also explains why [HTTPRequest setShouldWaitUntilDone:YES]
worked.
I was having this problem. This identified the issue. The class that was using the ObjectiveFlickr and making the API calls was held weakly within a block. Once the block finished, the instance was lost and, with it, the API call, delegate callbacks, etc. When I specified __strong __weak for that instance, it all worked again.
__strong __block HuFlickrServicer *servicer;
UITapGestureRecognizer *doubleTap = [UITapGestureRecognizer bk_recognizerWithHandler:^(UIGestureRecognizer *sender, UIGestureRecognizerState state, CGPoint location) {
LOG_UI(0, @"Double tap.");
servicer = [[HuFlickrServicer alloc]init];
[servicer like];
}];
@property (nonatomic,strong) OFFlickrAPIRequest *flickrRequest; ... ...
if (requestURL) {
[HTTPRequest setContentType:nil];
+ [HTTPRequest setShouldWaitUntilDone:YES];
return [HTTPRequest performMethod:LFHTTPRequestGETMethod onURL:requestURL withData:nil];
}
i add this line code marked by '+' ,but the callback can not be called!!