locoboy
locoboy

Reputation: 38940

Difference in NSMutableArray declaration

What is the difference between [NSMutableArray array] and [[NSMutableArray alloc] init]?

Upvotes: 0

Views: 383

Answers (2)

Terry Wilcox
Terry Wilcox

Reputation: 9040

[NSMutableArray array]

returns an autoreleased array.

[[NSMutableArray alloc] init]

returns a retained array.

You don't own the autoreleased array, so you don't have to release it. You own the retained one (with alloc), so you have to release it.

Upvotes: 2

Ole Begemann
Ole Begemann

Reputation: 135548

[NSMutableArray array] is equivalent to [[[NSMutableArray alloc] init] autorelease].

Upvotes: 3

Related Questions