If I have an interface defined like
@interface MyClass
@property (nonatomic, copy, readonly) NSString *myString;
@end
so that myString
is externally visible but can't be written, what would be the preferred coding style for redeclaring the property in the implementation? Would it be (a)
@property (nonatomic, copy) NSString *myString;
or (b)
@property (nonatomic, copy, readwrite) NSString *myString;
(I know that these two are exactly the same, this is a question purely about coding style!)
1 Answer 1
The preferred coding style would be (b) according to all style guides that I've seen (e.g. https://github.com/objc-zen/objc-zen-book#property-declaration). They recommend explicitly specify readwrite
attribute (for the sake of clarity, I guess).
-
I disagree - this answers my question perfectly. I don't know why it's been down-voted!deanWombourne– deanWombourne2015年05月08日 21:46:09 +00:00Commented May 8, 2015 at 21:46
Explore related questions
See similar questions with these tags.
(readwrite)
in the implementation will do.