Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

delegate callback doesn't get called when call callAPIMethodWithGET #34

Open
MelvinTo opened this issue May 18, 2012 · 8 comments
Open

Comments

@MelvinTo
Copy link

and if I manually set the shouldWaitUntilDone to YES before performing the http request, the callback can be called successfully.

@MelvinTo
Copy link
Author

    if (requestURL) {
        [HTTPRequest setContentType:nil];
  +    [HTTPRequest setShouldWaitUntilDone:YES];
        return [HTTPRequest performMethod:LFHTTPRequestGETMethod onURL:requestURL withData:nil];        
    }
    return NO;

@MelvinTo
Copy link
Author

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;
}

@MelvinTo
Copy link
Author

seems a bug of Xcode.

@MelvinTo MelvinTo reopened this May 18, 2012
@MelvinTo
Copy link
Author

not a bug of Xcode.

@tar500
Copy link

tar500 commented Apr 17, 2014

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?

@tar500
Copy link

tar500 commented Apr 17, 2014

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.

@bleeckerj
Copy link

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];
        }];

@ikallen
Copy link

ikallen commented Sep 11, 2015

@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!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants