How do I ensure objects passed to an initializer are copied, rather than only on setting those attributes later?
Using @NSCopying
, Apple says we can achieve copy
-property-like behavior. Per default, the attribute is only assigned though, without calling the setter which does the copying.
This is potentially dangerous as I want to rely on the property being immutable and not being modified without me knowing. (think of getting an NSMutableString
instead of NSString
- copying would give me an immutable instance).