A protocol that mutable objects adopt to provide functional copies of themselves.
- iOS 2.0+
- macOS 10.0+
- tvOS 9.0+
- watchOS 2.0+
NSMutable 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
NSMutable declares one method,
mutable, but mutable copying is commonly invoked with the convenience method
mutable method is defined for all NSObjects and simply invokes
mutable with the default zone.
If a subclass inherits
NSMutable from its superclass and declares additional instance variables, the subclass has to override
mutable to properly handle its own instance variables, invoking the superclass’s implementation first.