• 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
Memory management with arrays
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Memory management with arrays


  • Subject: Memory management with arrays
  • From: Jacob Bandes-Storch <email@hidden>
  • Date: Sat, 9 Feb 2008 19:48:48 -0800

I have an array that is an instance variable. I'm trying to add an object to it, and autorelease that object, so the next time this happens, I can remove all objects in the array and the object will be gone.

- (void)foo {
[array removeAllObjects];
Bar *bar = [[Bar alloc] init];
[array addObject:[bar autorelease];
}

This should remove all the objects, and add a new one. Basically, I want the old Bar instance gone, and the new one in the array. However, when I do this, I get an EXC_BAD_ACCESS when it tries to - removeAllObjects. What's the problem?
_______________________________________________


Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: Memory management with arrays
      • From: Scott Andrew <email@hidden>
    • Re: Memory management with arrays
      • From: Andrew Merenbach <email@hidden>
    • Re: Memory management with arrays
      • From: Jonathon Mah <email@hidden>
  • Prev by Date: Re: references to controllers in document based applications
  • Next by Date: Re: Logging Mechanisms in Cocoa
  • Previous by thread: Re: references to controllers in document based applications
  • Next by thread: Re: Memory management with arrays
  • Index(es):
    • Date
    • Thread