目标C中的^是什么意思? [英] What does ^ in objective C mean?

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

问题描述

目标C中的^字符是什么意思?就像下面的代码一样

What does ^ character in Objective C mean? like in the following code

TWTweetComposeViewControllerCompletionHandler 
    completionHandler =
    ^(TWTweetComposeViewControllerResult result) {
        switch (result)
        {
            ...
        }
        [self dismissModalViewControllerAnimated:YES];
    };

推荐答案

它表示一个块",可以将其打包成一个对象并在以后使用.在您的示例中,它指定了一个稍后要调用的完成处理程序,大概是在用户单击确定"或某些类似的按钮以关闭警报时.

It denotes a "block", a piece of code that can be packaged into an object and used later. In your example it specifies a completion handler to be called later, presumably when the user clicks "OK" or some similar button to close an alert.

块也可以与Grand Central Dispatch一起使用,在这种情况下,它们用于生成可在另一个线程上同步和异步运行的代码单元.

Blocks can also be used with Grand Central Dispatch and in that case they are used to produce a unit of code that can be run on another thread, both synchronously and asynchronously.

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

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