Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NSMutableArray alloc init vs NSMutableArray array

What is the differece between:

[[NSMutableArray alloc] init]

and

[NSMutableArray array]
like image 326
susitha Avatar asked Dec 19 '11 04:12

susitha


People also ask

What is difference between NSArray and NSMutableArray?

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.

What is NSMutableArray in Swift?

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 .

What is an 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.


1 Answers

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];

like image 105
Aakil Ladhani Avatar answered Oct 05 '22 13:10

Aakil Ladhani