• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Releasing what's in an array?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Releasing what's in an array?


  • Subject: Releasing what's in an array?
  • From: Mark Dawson <email@hidden>
  • Date: Fri, 25 Feb 2005 10:23:54 -0800

If I create a mutable array in my -init function:
self = [super init];
if (self) {
myArray = [[NSMutableArray allocWithZone:[self zone]] init];
}
return self;

Do I need to explicitly remove all pieces out the the array before releasing it in my dealloc routine?

[myArray removeAllObjects]; // is this step necessary?
[myArray release];
[super dealloc];

If I understand things, removing an object out of an array causes a release to happen (if there isn't a prior retain causing that object to be retained), so removeAllObjects would both remove and release all objects. However, does releasing the array itself have the same effect?

Thanks,

Mark

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: Releasing what's in an array?
      • From: Shawn Erickson <email@hidden>
    • Re: Releasing what's in an array?
      • From: Shawn Erickson <email@hidden>
  • Prev by Date: Re: Custom radio button failure with bindings [Solved]
  • Next by Date: Please help a newbie with delegation!
  • Previous by thread: Re: Loading Cocoa Bundles
  • Next by thread: Re: Releasing what's in an array?
  • Index(es):
    • Date
    • Thread