开发者

Does @property (readonly, retain) have a meaning?

开发者 https://www.devze.com 2023-01-19 20:06 出处:网络
XCode acc开发者_高级运维epts it. But will retain be applied when I internally set the property (no setter outside since readonly but when I initialize the value in a class method) ?

XCode acc开发者_高级运维epts it. But will retain be applied when I internally set the property (no setter outside since readonly but when I initialize the value in a class method) ?

Regards, Apple92


You might specify (readonly, retain) for a publicly-facing property, and then inside your .m, re-define it as (readwrite, retain) to be able to assign to it privately. I use this pattern myself occasionally.


The reason to do this is to allow you to do @property (retain) in a class continuation or category. If you don't have the retain on the outer property, you will get a warning about the properties being mismatched.


it's also nice as a form of interface documentation

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号