什么是“强”关键字do
我下载了Xcode 4.2开发者预览版本,我创建了一个可可应用程序。但是我在委托类中发现了一个非常奇怪的语法:
I downloaded the Xcode 4.2 developer preview version and I created a cocoa application. But I found a very weird syntax in the delegate class:
@property (strong) IBOutlet NSWindow *window;
这是什么意思?编译器甚至不能编译它。
What does this mean? And the compiler can't even compile it.
提前感谢!
它表明这个属性是一个强关系 - 一个所有权。 ARC 版本的保留
关键字在相同的上下文。
It indicates that this property is a strong relationship—an ownership. It's ARC's version of the retain
keyword in the same context.
编译器甚至无法编译它。
And the compiler can't even compile it.
这是有效的ARC代码,所以如果你的工具支持ARC,他们当然应该能够编译它。
It's valid ARC code, so if your tools support ARC, they certainly should be able to compile it.
使用Xcode 4.2或更高版本,并且您将项目的编译器选择设置为Clang(Apple LLVM Compiler)。
Make sure that you're using Xcode 4.2 or later, and that you have the project's compiler choice set to Clang ("Apple LLVM Compiler").