我已经根据文档设置了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不会被调用,几乎什么都不会发生。
发布于 2014-02-18 19:14:24
(是的,老问题,希望这能帮助其他人)
确保在分配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.
}https://stackoverflow.com/questions/17540528
复制相似问题