English 中文(简体)
ObjectiveC字符串文字的权威描述?关闭
原标题:Authoritative description of ObjectiveC string literals? [closed]
Closed. This question is opinion-based. It is not currently accepting answers.

想改进这个问题吗 通过编辑此帖子,更新问题,以便用事实和引用来回答。

Closed 6 years ago.

苹果ObjectiveC描述暗示NSString通过显示示例而存在,并且NSString字面量写为

 @ "<string content>"

令人惊讶的是,这就是它所说的,这些只出现在没有任何讨论的例子中。那份文件真的是唯一的参考文件吗?

四处搜寻,我发现这个博客似乎有很多有用的信息。但它是对的吗?

是否有权威文档准确描述了NSString文字中可以说什么(语法),以及它的含义(语义)?例如,NSString字面值的内容语法是否与C(99)字符串字面值的语法相同?ObjectiveC++中的语法不同吗?我可以像其他类型的C99/C++字符串一样,在字符串文字内容前加上宽度规范吗?还是只有一种NSString文字?黑暗的角落是什么?

还是我唯一的选择是深入研究GCC4和Clang的实现来找出答案?

问题回答

如果在文档和随机博客之间做出选择,我倾向于相信文档。

写的不多,因为没什么好说的@“..”是一个静态字符串常量。它是在编译时创建的,写入二进制文件,以只读方式映射到内存中,甚至比NSString实例本身更不可变(例如,常量NSString根本不实现保留计数;没有分配)。

除了编译器用于普通旧C字符串的正常语法外,没有与它们相关的真正语法。也就是说,你可以做大多数各种架线喷浆等。。。





相关问题
Logback tutorial [closed]

Where can I find a Logback tutorial and/or sample projects? Something similar with this "Log4j Tutorial" would be nice. Note: I am aware of the documentation available on the official Logback website ...

How to document the Main method? [closed]

Okay, so I ve got a .NET console application with it s Main method, contained in a Program class. You know, the usual: class Program { static void Main(string[] args) { // Do ...

javadoc: show also descriptions of methods from parent class

Is there a way to produce javadoc so that all methods accessible from the class are listed with their full description? Usually only the methods defined in that class are listed and the rest are only ...

Is there a list of known web crawlers? [closed]

I m trying to get accurate download numbers for some files on a web server. I look at the user agents and some are clearly bots or web crawlers, but many for many I m not sure, they may or may not be ...

热门标签