NSMutableCopying protocol declares a method for providing mutable copies of an object. Only classes that define an “immutable vs. mutable” distinction should adopt this protocol. Classes that don’t define such a distinction should adopt
NSMutableCopying declares one method,
mutableCopyWithZone:, but mutable copying is commonly invoked with the convenience method
mutableCopy method is defined for all NSObjects and simply invokes
mutableCopyWithZone: with the default zone.
If a subclass inherits
mutableCopyWithZone: to properly handle its own instance variables, invoking the superclass’s implementation first.
Returns a new instance that’s a mutable copy of the receiver.
zone: NSZone) -> AnyObject
- (id _Nonnull)mutableCopyWithZone:(NSZone * _Nullable)
The zone from which memory is allocated for the new instance. If
NULL, the new instance is allocated from the default zone, which is returned by
The returned object is implicitly retained by the sender, which is responsible for releasing it. The copy returned is mutable whether the original is mutable or not.
Available in iOS 2.0 and later.