What is the differece between:
[[NSMutableArray alloc] init]
and
[NSMutableArray array]
The primary difference between NSArray and NSMutableArray is that a mutable array can be changed/modified after it has been allocated and initialized, whereas an immutable array, NSArray , cannot.
Overview. The 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 NSArray .
NSArray creates static arrays, and NSMutableArray creates dynamic arrays. You can use arrays when you need an ordered collection of objects. NSArray is “toll-free bridged” with its Core Foundation counterpart, CFArrayRef . See Toll-Free Bridging for more information on toll-free bridging.
Here in [NSMutableArray array]
you don't have to release array
it will be released automatically. & if you will write [NSMutableArray alloc] init]
you will have to release array
so [[NSMutableArray array]
will be equivalent to [[[NSArray alloc] init] autorelease];
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With