Re: newbie question
Re: newbie question
- Subject: Re: newbie question
- From: "Stephen Deken" <email@hidden>
- Date: Fri, 10 Nov 2006 09:17:20 -0600
if i create a NSAutoreleasePool and add the dictionary to the pool,
it works fine:
You don't have to add the dictionary to the pool --
[NSMutableDictionary dictionaryWith...] does that for you. Creating
the pool is all you need to do (and you usually don't need to do even
that -- it's just that within your main() method, AppKit hasn't been
able to create one yet).
such as dictionaryWithCapacity: are deallocated automatically.
so why do i get this runtime error then?
They are deallocated automatically when the autorelease pool is
released. Autorelease pools hold references to objects, and release
all of them when the autorelease pool is released.
Saying this:
NSMutableDictionary *m = [NSMutableDictionary dictionaryWithCapacity:1];
is equivalent to this:
NSMutableDictionary *m = [NSMutableDictionary alloc];
[m initWithCapacity:1];
[m autorelease];
The [m autorelease] line adds the object to the current autorelease
pool. In general, this is the only way that an object can be added to
an autorelease pool -- you should never add an object to a specific
autorelease pool.
Stephen Deken
email@hidden
_______________________________________________
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