Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free.

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

share|improve this question
1  
Afaik just mentioning (readwrite) in the implementation will do. –  Jack Apr 13 at 10:22

1 Answer 1

up vote 0 down vote accepted

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

share|improve this answer
2  
This does not provide an answer to the question. To critique or request clarification from an author, leave a comment below their post - you can always comment on your own posts, and once you have sufficient reputation you will be able to comment on any post. –  GlenH7 May 8 at 13:20
    
I disagree - this answers my question perfectly. I don't know why it's been down-voted! –  deanWombourne May 8 at 21:46

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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