我有一个使用AFJSONRequestOperation的函数,我希望仅在成功后返回结果。你能指出我正确的方向吗?我对块和AFNetworking还是一无所知。
-(id)someFunction{
__block id data;
AFJSONRequestOperation *operation = [AFJSONRequestOperation JSONRequestOperationWithRequest:request
success:^(NSURLRequest *request, NSHTTPURLResponse *response, id json){
data = json;
return data; // won't work
}
failure:^(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error){
}];
NSOperationQueue *queue = [[NSOperationQueue alloc] init];
[queue addOperation: operation];
return data; // will return nil since the block doesn't "lock" the app.
}
慕村9548890
噜噜哒
慕虎7371278
相关分类