2

可能重复:
目标 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];
 }

提前致谢!

4

3 回答 3

5

^文字。块文字后面是参数,然后是花括号以指示代码的实际内容:

| ^          | (id arg)    | {};          |
|:-----------|------------:|:------------:|
| Block      | Parameters  |     Body     |
| literal    |             |              |

块文字在这里解释得很好。

于 2012-07-02T06:29:13.353 回答
3

^表示一个。在此处查看更多信息:http: //developer.apple.com/library/ios/#documentation/cocoa/Conceptual/Blocks/Articles/00_Introduction.html

实际上,这指定了一段将在以后执行的代码。

于 2012-07-02T06:29:27.553 回答
1

那些是块。你可以在这里阅读一个很好的介绍。然后阅读块编程主题以获取更多详细信息。

于 2012-07-02T06:29:43.317 回答