当property遇上category

当property遇上category

  @property可以在类定义中,以及extension定义中使用,编译器会自动为@property生成代码,并在变量列表(ivar_list_t)中添加相应的以下划线开头的变量。

  在category中,编译器允许定义@property,但不会为此@property生成代码,也即意味着编译器不会在变量列表中加入property的变量。必须人工的实现property的方法。

  

参考:https://developer.apple.com/library/mac/documentation/cocoa/conceptual/ProgrammingWithObjectiveC/CustomizingExistingClasses/CustomizingExistingClasses.html

原文地址:https://www.cnblogs.com/tekkaman/p/3753629.html