ObjC ARC:当ARC将对象设置为nil时,是否会运行弱属性的setter方法?

时间:2022-08-03 19:56:04

Really quick question (I could test it myself but not on a computer with Xcode):

真的很快问题(我可以自己测试但不能在带Xcode的计算机上测试):

If ARC sets a weak property to nil, will the property's setter run with the parameter being nil, or is the property setter bypassed in this case?

如果ARC将弱属性设置为nil,属性的setter是否会以参数nil运行,或者在这种情况下是否绕过属性setter?

1 个解决方案

#1


9  

No. ARC doesn't set properties to nil. It will set the backing ivar to nil, but that doesn't run your setter.

否.ARC不会将属性设置为nil。它会将支持ivar设置为nil,但这不会运行你的setter。

#1


9  

No. ARC doesn't set properties to nil. It will set the backing ivar to nil, but that doesn't run your setter.

否.ARC不会将属性设置为nil。它会将支持ivar设置为nil,但这不会运行你的setter。