美文网首页
iOS @synthesize 和 @dynamic 区别

iOS @synthesize 和 @dynamic 区别

作者: iOS_肖晨 | 来源:发表于2017-09-29 10:25 被阅读76次

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框架在程序运行的时动态生成子类属性。

相关文章

网友评论

      本文标题:iOS @synthesize 和 @dynamic 区别

      本文链接:https://www.haomeiwen.com/subject/jbnbextx.html