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!)

asked Apr 13, 2015 at 9:28
1
  • 1
    Afaik just mentioning (readwrite) in the implementation will do. Commented Apr 13, 2015 at 10:22

1 Answer 1

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).

answered May 8, 2015 at 12:22
1
  • I disagree - this answers my question perfectly. I don't know why it's been down-voted! Commented May 8, 2015 at 21:46

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.