# How to relase NSDictionary



## diyora (Aug 17, 2008)

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..


----------



## Captain Code (Aug 18, 2008)

We can't talk specifically about anything to do with the iPhone SDK due to the NDA.  However your question is generic Objective-C and the reason for your error is that you have created an auto released NSDictionary.

Class methods denoted by a + as opposed to a -, are as far as I know always autorelease objects.  Your application will have an autorelease pool set up unless you have changed something.

```
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
....
[pool release];
```

You can try and put your call in between the alloc and release of an autorelease pool you create yourself and that should solve the problem.

Check the documentation for NSAutoreleasePool by searching in XCode's help menu in order to find out more information about what an autorelease pool is and why you might need to create one.


----------

