1

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
    Afaik just mentioning (readwrite) in the implementation will do. – Jack Apr 13 '15 at 10:22
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 May 8 '15 at 21:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.