iOS @synthesize 和 @dynamic 区别

1. @property中的 @synthesize 和 @dynamic 区别:

@synthesize will generate getter and setter methods for your property.

@synthesize 能够为你的属性自动生成getter和setter方法。

@dynamic just tells the compiler that the getter and setter methods are implemented not by the class itself but somewhere else(like the superclass)

@dynamic 会告诉编译器:getter和setter方法在别处生成了(比如父类中),并没有在本类生成。

Uses for @dynamic are e.g. with subclasses of NSManagedObject(CoreData) or when you want to create an outlet for a property defined by a superclass that was not defined as an outlet;

运行时动态创建绑定:主要使用在CoreData的实现NSManagedObject子类时使用,由Core Data框架在程序运行的时动态生成子类属性。

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

友情链接更多精彩内容