English 中文(简体)
@property of object-c 的@property
原标题:The @property of Objective-c

以下事实属实:

弱 = 不安全不保存= 指派

强 = 保留

如果这就是为什么它们被复制的原因?我们应该选择哪一个呢?

最佳回答

否,它不是真实的。 weak 表示对象不保留,此外,当对象进行交易时,变量/财产将自动设定为零。 unsafe_unreservated 表示对象不保留,但没有自动零化。 strong restin 是等同的。

问题回答

sign > 通常用于原始物,如 < int twoble ,因为您只是重新指派。 unsafe_unreservated 用于目标C对象,但您不保留这些物体,并理解为什么这种物体不安全。 weak 是iOS 5中引入的一个新特征,它类似于 unsefree_unressunreed ,但与 ARC有不同的语义。请查看苹果 s < a href="。 < a href="https:// developer.apple.com/library/mac/documentation/Cocoa/defitutional/MoryMgmt/Mgmt.pdf" rel=“nofol=“nofolt> > Advanced mememorment management 指南,

在实际操作中,如果目标为iOS 5或更高,则几乎永远也不会使用unsafe_unreserve

  • strong: variable is retained during its scope. retain also works as a synonym for strong.
  • copy: creates and retains a copy.
  • weak: use it to point to an object without claiming ownership. Once the object is released, the pointer will be nil ed.
  • unsafe_unretained: same as weak but doesn t nil the pointer after release.
  • assign: primitive values.

If you re targeting iOS 4, you cannot use weak. Use unsafe_unretained instead.
Before ARC, the default on properties was assign, now the default is strong.

weak != unseafe_unretain

weak 将自动将其指针转换为 nil ,如果它指向的对象是交易地点的话。

未来您应该使用 strong & amp; weak 用于对象,使用 sign 用于原始类型





相关问题
Code sign Error

I have created a new iPhone application.I have two mach machines. I have created the certificate for running application in iPhone in one mac. Can I use the other mac for running the application in ...

ABPersonViewController Usage for displaying contact

Created a View based Project and added a contact to the AddressBook using ABAddressBookRef,ABRecordRef now i wanted to display the added contact ABPersonViewController is the method but how to use in ...

将音频Clips从Peter改为服务器

我不禁要问,那里是否有任何实例表明从Peit向服务器发送音响。 I m不关心电话或SIP风格的解决办法,只是一个简单的袖珍流程......

• 如何将搜查线重新定位?

我正试图把图像放在搜索条左边。 但是,问题始于这里,搜索条线不能重新布署。