iOS @synthesize 和 @dynamic 區(qū)別

1. @property中的 @synthesize 和 @dynamic 區(qū)別:

@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;

運行時動態(tài)創(chuàng)建綁定:主要使用在CoreData的實現(xiàn)NSManagedObject子類時使用,由Core Data框架在程序運行的時動態(tài)生成子類屬性。

最后編輯于
?著作權歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務。

相關閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容