我正在使用 Facebook SDK 3,它使用 Blocks 作为 CompletionHandlers。我想在传递块中使用局部范围变量(参数)到 FBRequestConnection
-(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];
}
}
我如何在 Block 范围内使用 HID,但我无法将它存储在类中!