Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
XCode 接受它。但是当我在内部设置属性时会应用保留(因为只读,但是当我在类方法中初始化值时没有设置器)?
问候, Apple92
您可以指定(readonly, retain)一个面向公众的属性,然后在您的 .m 中重新定义它(readwrite, retain)以便能够私下分配给它。我自己偶尔也会使用这种模式。
(readonly, retain)
(readwrite, retain)
这样做的原因是为了让你@property (retain)在一个类延续或类别中做。如果您在外部属性上没有保留,您将收到有关属性不匹配的警告。
@property (retain)
作为界面文档的一种形式也很好