什么是Objective-C中的"^" [英] What is the '^' in Objective-C

查看:316
本文介绍了什么是Objective-C中的"^"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

@implementation AppController

- (IBAction) loadComposition:(id)sender
{
    void (^handler)(NSInteger);

    NSOpenPanel *panel = [NSOpenPanel openPanel];

    [panel setAllowedFileTypes:[NSArray arrayWithObjects: @"qtz", nil]];

    handler = ^(NSInteger result) {
        if (result == NSFileHandlingPanelOKButton) {
            NSString *filePath = [[[panel URLs] objectAtIndex:0] path];
            if (![qcView loadCompositionFromFile:filePath]) {
                NSLog(@"Could not load composition");
            }
        }
    };

    [panel beginSheetModalForWindow:qcWindow completionHandler:handler];
}
@end

=== 我已经搜索了-是对内存的某种特定引用吗?

=== I've searched and searched - is it some sort of particular reference to memory?

推荐答案

仔细阅读

Read up on it here. It's a "Block object", which is basically a lambda form, and was introduced to support Snow Leopard's GCD (Grand Central Dispatch).

这篇关于什么是Objective-C中的"^"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆