newbie question
newbie question
- Subject: newbie question
- From: maximilian marcoll <email@hidden>
- Date: Fri, 10 Nov 2006 16:07:34 +0100
hi!
i'm new to this list (and new to cocoa and objective-c, too) and i
hope not to bother you with this beginner-stuff...
as it seems, this is about a general lack of understanding:
in my main.m file, the only thing i do is instantiating an object of
the class NSMutableDictionary with:
NSMutableDictionary * dict = [NSMutableDictionary
dictionaryWithCapacity:1];
and i get a runtime error:
_NSAutoreleaseNoPool(): Object 0x306800 of class NSCFDictionary
autoreleased with no pool in place - just leaking
if i do:
NSMutableDictionary * dict = [NSMutableDictionary
dictionaryWithCapacity:1];
[dict writeToFile: [NSString stringWithFormat:@"/Users/max/Desktop/
test.plist"] atomically:YES];
i get a bunch of such runtime errors.
if i create a NSAutoreleasePool and add the dictionary to the pool,
it works fine:
NSAutoreleasePool *pool =[[NSAutoreleasePool alloc] init ];
NSMutableDictionary * dict = [NSMutableDictionary
dictionaryWithCapacity:1];
[pool addObject:dict];
[dict retain];
do i have to create a NSAutoreleasePool, adding every single object i
create to the pool myself?
apple's "The Objective-C Programming Language" says that instances
created with a class method
such as dictionaryWithCapacity: are deallocated automatically.
so why do i get this runtime error then?
and what about a classes instance variables?
say, i have a class a, and in its init method i want to create such a
NSMutableDictionary.
if i have to add it to a NSAutoreleasePool, which pool do i add it to?
does this make any sense?
any help would be really great.
thank you!
- confused -
max
_____________________________________________
m a x i m i l i a n m a r c o l l
http://www.maximilianmarcoll.de
d i s . p l a y c e
http://dis.playce.info
_______________________________________________
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