可能重复:
Caret in objective C
^符号在Objective-C中意味着什么?
代码:
GreeRequestServicePopup* requestPopup = [GreeRequestServicePopup popup];
requestPopup.parameters = parameters;
requestPopup.willLaunchBlock = ^(id aSender) {
[[NSNotificationCenter defaultCenter] postNotificationName:@"request_service_popup_will_launch_block" object:nil];
};
requestPopup.didLaunchBlock = ^(id aSender) {
[[NSNotificationCenter defaultCenter] postNotificationName:@"request_service_popup_did_launch_block" object:nil];
};
requestPopup.willDismissBlock = ^(id aSender) {
[[NSNotificationCenter defaultCenter] postNotificationName:@"request_service_popup_will_dismiss_block" object:nil];
};
requestPopup.didDismissBlock = ^(id aSender) {
[[NSNotificationCenter defaultCenter] postNotificationName:@"request_service_popup_did_dismiss_block" object:nil];
};
requestPopup.cancelBlock = ^(id aSender) {
[[NSNotificationCenter defaultCenter] postNotificationName:@"request_service_popup_cancel_block" object:nil];
};
requestPopup.completeBlock = ^(id aSender) {
[[NSNotificationCenter defaultCenter] postNotificationName:@"request_service_popup_complete_block" object:nil];
};
[self.navigationController showGreePopup:requestPopup];
}
提前致谢!
答案 0 :(得分:5)
^
是一个block字面值。块文字后跟参数,然后是花括号以表示代码的实际内容:
| ^ | (id arg) | {}; |
|:-----------|------------:|:------------:|
| Block | Parameters | Body |
| literal | | |
块文字的解释相当清楚here。
答案 1 :(得分:3)
实际上,这指定了将在稍后执行的一段代码。
答案 2 :(得分:1)
那些是块。你可以阅读一篇很好的介绍here。然后阅读Blocks Programming Topics了解更多详情。