• 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
NSMutableArray and releases etc
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

NSMutableArray and releases etc


  • Subject: NSMutableArray and releases etc
  • From: Alan leigh <email@hidden>
  • Date: Fri, 11 Oct 2002 02:03:07 +1000

Hi all... I have code which does some fairly lengthy iterations... so naturally I cop any memory leaks pretty hard. I'm trying to figure out where I'm leaking some.. and here is my question (I know, I know I should re-write my code to use a C, or real man (or woman's) array, but right now I'm still testing a few things before I go for speed). Anyway, the question.. so I have this...

NSMutableArray* ratings;

[ratings addObject:[NSNumber numberWithFloat:[self someFnWhichReturnsFlt]]];

So as i understand it... I can assume the NSNumber is autoreleased but gets a +1 retain from the addObject. If I'm careful to not just release ratings, but also 'removeAllObjects' I guess that's ok.. but what if ratings just dies as a result of its auto release (assuming it too is temporary)?? Is this just bad coding or can I account for it? Or does Array send a release to all it's objects as it dies (which would be consistent with addObject: and removeObject: I guess... but i can't find any documentation of it...

Cheers,

Alan (staring at a 'top' screen) :)
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

  • Follow-Ups:
    • Re: NSMutableArray and releases etc
      • From: Ondra Cada <email@hidden>
  • Prev by Date: Re: case-insensitive strings - It's already in NSString!
  • Next by Date: Re: Carbon vs Cocoa arguments
  • Previous by thread: Re: Wrapping C
  • Next by thread: Re: NSMutableArray and releases etc
  • Index(es):
    • Date
    • Thread