Skip to content

Commit bb2668c

Browse files
committed
Updated with preference of copy over strong.
Updated with preference of copy over strong when a class has a mutable counterpart.
1 parent 57c6475 commit bb2668c

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

README.md

+13
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,20 @@ Property attributes should be explicitly listed, and will help new programmers w
299299
@property (nonatomic) NSString *tutorialName;
300300
```
301301

302+
Properties with mutable counterparts (e.g. NSString) should prefer `copy` instead of `strong`.
303+
Why? Even if you declared a property as `NSString` somebody might pass in an instance of an `NSMutableString` and then change it without you noticing that.
302304

305+
**Preferred:**
306+
307+
```objc
308+
@property (copy, nonatomic) NSString *tutorialName;
309+
```
310+
311+
**Not Preferred:**
312+
313+
```objc
314+
@property (strong, nonatomic) NSString *tutorialName;
315+
```
303316

304317
## Dot-Notation Syntax
305318

0 commit comments

Comments
 (0)