0
我正在使用Facebook SDK 3,它使用Blocks作为CompletionHandlers。 我想在传递块使用局部范围的变量(自变量)来FBRequestConnectionObjC使用块中的变量在另一个类中触发
-(void) shareStoryWithHandle:(const int)HID parameters:(NSString*)jsonparams
{
if (FBSession.activeSession.isOpen)
{
FBRequestHandler my_handler = ^(FBRequestConnection *connection, id result, NSError *error)
{
// do somthing with HID
// but HID is 0 in this scope while is correct in shareStoryWithHandle scope!
}
[FBRequestConnection startWithGraphPath:@"me/feed"
parameters:[jsonparams objectFromJSONString]
HTTPMethod:@"POST"
completionHandler:my_handler];
}
}
如何使用HID在块范围,我不能把它存储在上课!
我不知道我怎么能断言它错了! NSLog(@“HID:%d”,HID); //在shareStoryWithHandle范围内返回1 NSLog(@“HID:%d”,HID); //在块范围内返回0 – Penman
急@Kevin Ballard写, 两个值都是0! 这个问题完全来自别的地方,我是这样一个不注意的人...... – Penman