vadivelu
vadivelu

Reputation: 508

How to release Array objects in iphone

An array has contains multiple objects.If we call removeAllObjects method, Whether objects will be released which in an array or we have release manually.

Upvotes: 0

Views: 389

Answers (3)

Parth Bhatt
Parth Bhatt

Reputation: 19469

You should do this to release your array. Better to release it this way rather than autoreleasing the array

[YourArray release];
YourArray = nil;

If you just want to get rid of the data and dont want to release the array then you can simply do:

YourArray = nil;

It is better to release array using [YourArray release] statement then declaring it as autorelease in declaration.

Hope this helps you.

Upvotes: 0

Jhaliya - Praveen Sharma
Jhaliya - Praveen Sharma

Reputation: 31720

You shouldn't need to remove all objects before you release. When an NSMutableArray is dealloc'd, it releases all of the objects in contains automatically.

More click here

Upvotes: 0

BoltClock
BoltClock

Reputation: 724142

Sending an NSArray that message will cause it to release all its pointers. You don't need to release what you put in there yourself, unless you have your own pointers to those objects elsewhere.

Upvotes: 3

Related Questions