为什么我的块声明给我一个不兼容的指针错误?

时间:2012-07-08 19:50:53

标签: objective-c ios xcode objective-c-blocks

我正在声明这样一个块:

void (^callback)(NSString *_accessToken) = ^{
  // do something interesting with _accessToken
}

但是XCode一直告诉我

Incompatible block pointer types initializing void(^__strong)(NSString *__strong)
with an expression of type void (^)(void)

我做错了什么?

1 个答案:

答案 0 :(得分:4)

void (^callback)(NSString *) = ^(NSString *_accessToken){
  // do something interesting with _accessToken
}