Ken*_*Ken 2 objective-c ios objective-c-blocks
可能重复:
目标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];
}
Run Code Online (Sandbox Code Playgroud)
提前致谢!
^是一个块字面.块文字后面跟着参数,然后是花括号来表示代码的实际内容:
| ^ | (id arg) | {}; |
|:-----------|------------:|:------------:|
| Block | Parameters | Body |
| literal | | |
Run Code Online (Sandbox Code Playgroud)
块文字在这里解释得相当好.
| 归档时间: |
|
| 查看次数: |
1553 次 |
| 最近记录: |