Rabskatran
Rabskatran

Reputation: 2309

NSMutableArray initialization methods

Is there a difference between [NSMutableArray array] and [[NSMutableArray alloc] init] ?

Upvotes: 0

Views: 162

Answers (1)

dreamlax
dreamlax

Reputation: 95405

[[NSMutableArray alloc] init] returns a mutable array that you own (and therefore have to explicitly relinquish ownership using release when you no longer need it) and [NSMutableArray array] returns a mutable array that you don't own.

According to the Memory Management Rules, any method with the word alloc, new, or create in the name, implies that you own the object returned from that method.

Upvotes: 4

Related Questions