BUG-Auto property synthesis will not synthesize property 'description' because it is 'readwrite'

今天遇见实现一个网络请求接口的遇到一个问题:

@property (nonatomic, strong)NSString * description;    //O 描述:最长256字节

报错:

Auto property synthesis will not synthesize property 'description' because it is 'readwrite' but it will be synthesized 'readonly' via another property

看了一下才知道,是接口那边定义的字段有问题,做开发的都知道,在代码中有许多特殊字段是不能随便使用的,系统会给你warning提示,


恰好这个descripton就跟系统字典重合了,so 百度了一下,

原因:
是因为 compiler 读取 sub-class 时,会发现 description 明明应该是个 readonly property(super-class 讲的),但你却要将它设为 readwriteproperty,所以 compiler 不知道该怎么 auto synthesis。

解决方法:

#import "AddPrivacyRecord.h"

@implementation AddPrivacyRecord

@dynamic description;


.m文件中 @dynamic一下就OK了哦。

参考的blog:http://blog.csdn.net/l863784757/article/details/46374939
发布了84 篇原创文章 · 获赞 107 · 访问量 24万+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章