Protocol for object copying in mulle-objc.
-copy
- Creates and returns a copy of the receiverIf your class can avoid supporting NSCopying or NSMutableCopying or anything like it, you probably have made your life a lot easier. The problems with -copy are:
It’s recommended to put this in your -copy method:
assert( MulleObjCClassImplementsSelector( [self class], @selector( copy)) &&
"your subclass must implement -copy and then start by "
"calling [super copy] then add additional copy code");
A -copy with respect to NSCopying: - Returns another instance of the receiver - Should be as indistinguishable from the receiver as possible - For immutable objects, returns a retained instance of the receiver - Used for creating snapshots or instances from prototypes - Used by properties - Not used by NSDictionary (which uses MulleObjCImmutableCopying for keys)
Note: The old copyWithZone: is gone. If you have copyWithZone: methods, code a method -copy that calls your -copyWithZone:.