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

你可能感兴趣的:(iOS @synthesize 和 @dynamic 区别)