objectiveflickr身份验证失败

时间:2013-07-09 05:22:24

标签: ios objectiveflickr

我根据文档设置了ObjectiveFlickr,我在按钮操作中写了这个块

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

但是当我点击按钮时会发生无关紧要的事情

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

没有被调用,几乎什么都没发生

1 个答案:

答案 0 :(得分:1)

(是的,老问题,希望这会帮助其他人)

确保在分配OFFlickrRequest对象时,以某种方式保留它,例如使其成为类的属性而是局部变量。如果只将它存储在当前范围内,ARC将在您退出范围时将其删除,因此当异步fetchOAuthRequest调用返回时,它将不会引用委托调用的内容。

即。这是错误的:

- (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.
}