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 weak
attribute is kept. The same is true for the assign
and strong
attributes - you can specify them in the .h
and omit them in the .m
, if you do include them in the .m
the 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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With