Auto property synthesis will not synthesize property 'description' because it is 'readwrote' but it will be synthesized 'readonly' via another property
想用MJExtension進行字典模型轉(zhuǎn)換娘赴,模型頭文件中定義了一個description屬性
Model.h
@property (nonatomic, strong) NSString *description;
然后就出現(xiàn)了如上警告烤黍。
原因是因為 compiler 讀取 sub-class 時,會發(fā)現(xiàn) description 明明應(yīng)該是個 readonly property(super-class 講的)凄杯,但你卻要將它設(shè)為 readwrite property寄雀,所以 compiler 不知道該怎么 auto synthesis。
解決方法
Model.m
@implementation AModel
@dynamic description;
@end
這樣雖然沒了警告,但是還是取不到值。查看后的解決方法
+ (NSDictionary *)replacedKeyFromPropertyName{
return @{@"Description":@"description"};
}
把屬性名改成大寫D開頭臀叙,或者隨便取一個屬性名,然后用上面的方法岗仑,字典的key就是你定義的屬性名,后面的就是你請求的后臺數(shù)據(jù)對應(yīng)的Key聚请。問題解決荠雕。