目标C中符号^的含义 [英] Meaning of symbol ^ in Objective C

查看:115
本文介绍了目标C中符号^的含义的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


可能重复:

目标C中的插入符号

这个^语法在Objective-C中意味着什么?

我是厌倦了在目标C中搜索符号^的含义。我在许多项目中都看到了它,特别是在后台运行任务中。我将链接
http://developer.apple.com/library/ios/#samplecode/StitchedStreamPlayer/Introduction/Intro.html#//apple_ref/doc/uid/DTS40010092
in MyStreamingMovieViewController.m 你可以在里面找到以下内容 - (IBAction)endScrubbing:(id)sender方法

I am tired by searching the meaning of symbol ^ in Objective C. I have seen it in lot of projects especially in back ground running tasks. I will put a link http://developer.apple.com/library/ios/#samplecode/StitchedStreamPlayer/Introduction/Intro.html#//apple_ref/doc/uid/DTS40010092 and in MyStreamingMovieViewController.m you can find the following inside - (IBAction)endScrubbing:(id)sender method.

timeObserver = [[player addPeriodicTimeObserverForInterval:CMTimeMakeWithSeconds(tolerance, NSEC_PER_SEC) queue:dispatch_get_main_queue() usingBlock:
                         ^(CMTime time)
                         {
                             [self syncScrubber];
                         }] retain];
    }

此外 http://developer.apple.com/library/ios/#documentation/iphone/conceptual/iphoneosprogrammingguide/ManagingYourApplicationsFlow /ManagingYourApplicationsFlow.html

- (void)applicationDidEnterBackground:(UIApplication *)application
{
UIApplication*    app = [UIApplication sharedApplication];

bgTask = [app beginBackgroundTaskWithExpirationHandler:^{
    // Clean up any unfinished task business by marking where you.
    // stopped or ending the task outright.
    [app endBackgroundTask:bgTask];
    bgTask = UIBackgroundTaskInvalid;
}];

// Start the long-running task and return immediately.
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{

    // Do the work associated with the task, preferably in chunks.

    [app endBackgroundTask:bgTask];
    bgTask = UIBackgroundTaskInvalid;
});
}

请告诉我答案。

推荐答案

该符号用于声明块。

欲了解更多信息,请阅读阻止编程主题

For more information read here Blocks Programming Topics

更多信息:


块对象是C级语法和运行时功能。它们是
类似于标准C函数,但除了可执行代码
之外,它们还可能包含对自动(堆栈)或
托管(堆)内存的变量绑定。因此,一个块可以维护一组状态
(数据),它可以用来影响执行时的行为。

Block objects are a C-level syntactic and runtime feature. They are similar to standard C functions, but in addition to executable code they may also contain variable bindings to automatic (stack) or managed (heap) memory. A block can therefore maintain a set of state (data) that it can use to impact behavior when executed.

你可以使用块来组成函数表达式可以将
传递给API,可选地存储,并由多个线程使用。块是
特别有用作回调,因为块带有要在回调时执行的
代码和
执行期间所需的数据。

You can use blocks to compose function expressions that can be passed to API, optionally stored, and used by multiple threads. Blocks are particular useful as a callback because the block carries both the code to be executed on callback and the data needed during that execution.

这篇关于目标C中符号^的含义的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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