当我在给一个类设置@property属性的时候,报了如下:“Auto property synthesis will not synthesize property 'contentView' because it is 'readwrite' but it will be synthesized 'readonly' via another property”错误。
之所以有这样的错误,是因为我定义了这样的property属性,而contentView属性是UIView控件内置的属性,如下:
//内容view @property (nonatomic, strong) UIView *contentView;
根据英文意思我们知道系统UIView控件的contentView属性是readonly只读的,如下:
@property (nonatomic, readonly, strong) UIView *contentView;
而小编我上方定义的内容view是可读可写的(readwrite),因此才报了“Auto property synthesis will not synthesize property 'contentView' because it is 'readwrite' but it will be synthesized 'readonly' via another property”错误。
解决方法:
将自己在一个类中定义的属性重新改一个名字,例如:
@property (nonatomic, strong) UIView *contentView; 改成 @property (nonatomic, strong) UIView *myView;
完美解决!