本文介绍了在Objective-C继承中使用@ synthesize / @属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如果你有一个实例varfoo有一个@ property / @ synthesize指令的类A,而B类继承自A类,它还需要@ property / @ synthesizefoo?我问的原因是,当我试图使用B类的foo,调用类说,foo不是一个结构化的联合或成员,这使我相信它需要显式合成。
If you have Class A with an instance var "foo" which has a @property/@synthesize directive, and Class B inherits from Class A, does it also need to @property/@synthesize "foo"? The reason I ask is because when I try to use Class B's "foo", the calling class says that "foo" is not something of a structured union or a member, which makes me believe it needs to be explicitly synthesized.
推荐答案
不,你不会。合成的属性将自动添加到类A及其子类。
No, you don't. Synthesized properties are added to class A and its subclasses automatically.
这篇关于在Objective-C继承中使用@ synthesize / @属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!