iOS 在 Objective-C 中构建和返回对象的这种方式的名称 [英] iOS Name of this way of building and returning an object in Objective-C

查看:15
本文介绍了iOS 在 Objective-C 中构建和返回对象的这种方式的名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道这种编码风格叫什么,它是内联块吗?内联作用域?什么?编译器遇到其中之一时会创建什么...

I'm trying to find out what this style of coding is called, is it an inline block? inline scope? what? What will the compiler create when it comes across one of these...

- (UIView *)createMyView {
      return
        ({
           UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 0)];
            /* set some stuff up on the view;
   */     
           view;

        });
}

我之所以这么问是因为我们在崩溃日志中收到了很多 cxx_destruct 调用,其中的行数远大于文件的实际大小.我想知道这种编码方式是否为其构建方式添加了一些奇怪的东西.

I'm asking because we're getting a lot of cxx_destruct calls in a crash log with lines numbers that are way bigger than the actual size of the file. I'm wondering if this way of coding adds some weird stuff to the way its built.

推荐答案

那是一个语句表达式",这是一个 GCC 特性(Clang 也理解),参见 http://gcc.gnu.org/onlinedocs/gcc/Statement-Exprs.html:

That is a "Statement Expression", which is a GCC feature (understood by Clang as well), see http://gcc.gnu.org/onlinedocs/gcc/Statement-Exprs.html:

括在括号中的复合语句可能显示为GNU C 中的表达式.这允许您使用循环、开关和本地表达式中的变量.

A compound statement enclosed in parentheses may appear as an expression in GNU C. This allows you to use loops, switches, and local variables within an expression.

表达式的值是复合语句中最后一个子表达式的值.

The value of the expression is the value of the last subexpression in the compound statement.

这篇关于iOS 在 Objective-C 中构建和返回对象的这种方式的名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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