Search code examples
iphonensmutablearraynsarray

Difference between NSArray and NSMutableArray


What is the difference b/w NSArray and NSMutableArray?


Solution

  • NSMutableArray (and all other classes with Mutable in the name) can be modified. So, if you create a plain NSArray, you cannot change its contents later (without recreating it). But if you create an NSMutableArray, you can change it — you'll notice it has methods like -addObject: and -insertObject:atIndex:.

    See the documentation for details.