I have the following code:
// MyObject.h #import <Foundation/Foundation.h> @interface MyObject : NSObject @property (nonatomic, readonly) id property; @end // MyObject.m #import "MyObject.h" @interface MyObject () @property (nonatomic, copy, readwrite) id property; @end @implementation MyObject @synthesize property = _property; @end
This generates the following warnings and compiler errors:
warning: property attribute in continuation class does not match the primary class @property (nonatomic, copy, readwrite) id property; ^ note: property declared here @property (nonatomic, readonly) id property; ^ error: ARC forbids synthesizing a property of an Objective-C object with unspecified ownership or storage attribute
However, if I change the reassessment of the class continuation property to get the weak storage qualifier, no warnings or errors are generated. However (disturbing?) The generated code for -[MyObject setProperty:] calls objc_storeStrong , not the expected objc_storeWeak .
I understand that with LLVM 3.1 the default repository for synthesized ivars strong default. I believe my question is this: why does codegen advocate for a headline declaration over my update in an implementation? Secondly, why does he complain when I upgrade as copy , but not weak or assign ?
source share