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

查看:112
本文介绍了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天全站免登陆