If I have a property like this:
//test.h
@interface test
@property (nonatomic, readonly, weak) NSObject x;
@end
redefined in the implementation file to be read/write:
// test.m
@interface test ()
@property (nonatomic, readwrite) NSObject x;
@end
I used weak in .h, but I said nothing in the extension, will the property keep the 'weak' specifier, or will it change to 'strong'?
Will the keywords strong/assign/weak be overwritten when the property is redefined?
A simple test with Xcode 5.1.1 shows the
weakattribute is kept. The same is true for theassignandstrongattributes - you can specify them in the.hand omit them in the.m, if you do include them in the.mthe two must match.Having said that, I do not know if this is documented anywhere. But then the semantics of Objective-C are not formally defined anywhere either. So use at your own risk.
Recommendation: just repeat it.