【发布时间】:2016-03-19 06:16:37
【问题描述】:
当使用= @"" 给NSString 赋值时,这个简写到底是什么意思?我注意到,在应用程序中所有其他条件相同的情况下,使用@"" 制作的全局NSStrings 不需要在赋予它们该值的方法之外使用retain,而NSStrings 给出了任何其他方式的价值。
我发现这个问题完全无法搜索,因此感谢您抽出宝贵时间。
【问题讨论】:
-
clang.llvm.org/docs/ObjectiveCLiterals.html 可能会有所帮助,它们通常被称为
Literals - NSStrings 从一开始就在语言中有点特别,我想不出一种方法来创建一个没有它们的 NSString,除了来自一个 char 数组。 -
密切相关:Purpose of @ symbol before strings 和 How ObjC handles the memory of immutable strings?(顺便说一句,DuckDuckGo 会搜索符号。)
-
谢谢。 @JoshCaswell 感谢您提供 DuckDuckGo 的提示!
标签: ios objective-c macos