0

如何将 typedef void 传递给方法

我有一个 typedef

typedef void (^FBLoginHandler)(id <FaceBook>,bool,NSError *error);

FBLoginHandler 测试处理程序;

^(id<FBLoginHandler>, bool, NSError *)error

[login log:@"AccessToken" handler:^(id<FBLoginHandler>, bool, NSError *)error];

谁能建议我如何将 typedef 值传递给方法

 [login log:@"AccessToken" handler:???];
4

1 回答 1

2
[login log:@"AccessToken" handler:^(id<FaceBook> object, bool trueOrFalse, NSError *error){
    // ... do whatever you'd like to do here.
}];

或者...

void ^(handlerBlock)(id<FaceBook>, bool, NSError *) = ^(id<FaceBook> object, bool trueOrFalse, NSError *error) {
    // ... do whatever you'd like to do here
};

[login log:@"AccessToken" handler:handlerBlock];

或者...

[login log:@"AccessToken" handler:nil];
于 2013-02-20T13:45:49.633 回答