Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

diyora

macrumors newbie
Original poster
Jul 21, 2008
25
0
Hello all,
I am coding in cocoa for iPhone simulator.
I used..
for(int i = 0 ; i < 5 ; i++)
{
[menuList addObject: [NSDictionary dictionaryWithObjectsAndKeys:
@"sdf",kTitleKey,
@"sfs",kExplainKey,
@"dgd",kWebKey,
@"sdfsf",kPublishDateKey,
nil]];
}

Now when i run code then i get console warning:
NSAutoreleaseNoPool(): Object 0x10979c0 of class NSCFDictionary autoreleased with no pool in place - just leaking..

It create problem for me some time.

Thank you..
 

robbieduncan

Moderator emeritus
Jul 24, 2002
25,611
893
Harrogate
dictionaryWithObjectsAndKeys: returns an autoreleased NSDictionary. At some point in the future (normally the end of this or the start of the next time throug the run loop) this will be released/dealloced for you. This happens by the magic of a NSAutoreleasePool. For autoreleasing to work you need to have a NSAutoreleasePool instance. Normally you have one created when the application starts. Looking in the main file for my iPhone projects one is automatically created there for me. Have you edited this to remove it? If so add it back.

You can also create your own autorelease pool for performance reasons. For example if your method is going to create a lot of autoreleased objects you might want them to get cleaned up faster than the normal system would. To do this you use

Code:
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
... You code here ..
[pool release];

Hope that helps...
 

diyora

macrumors newbie
Original poster
Jul 21, 2008
25
0
Hi,
thanks for reply..
I can't edit main file.NSAutoreleasePool is there.
I also put NSAutoreleasepool out for loop as i mention previous post.

But i create problem for me to create table..

thank you...
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.