NSMutableArray class declares the programmatic interface to objects that manage a modifiable array of objects. This class adds insertion and deletion operations to the basic array-handling behavior inherited from
- iOS 2.0+
- macOS 10.0+
- tvOS 9.0+
- watchOS 2.0+
Accessing Values Using Subscripting
In addition to the provided instance methods, such as
replaceObject(at:with:), you can access
NSArray values by their indexes using subscripting.
There is typically little reason to subclass
NSMutableArray. The class does well what it is designed to do—maintain a mutable, ordered collection of objects. But there are situations where a custom
NSArray object might come in handy. Here are a few possibilities:
NSMutableArraystores the elements of its collection. You might do this for performance reasons or for better compatibility with legacy code.
Acquiring more information about what is happening to the collection (for example, statistics gathering).