I getting leak here which is written in the appDelegate.m
-(NSMutableArray*)getSalutationList
{
NSMutableArray *list=[[NSMutableArray alloc]init];
[list addObject:@"Dr."];
[list addObject:@"Mr."];
[list addObject:@"Mrs."];
[list addObject:@"Miss."];
[list addObject:@"Ms."];
return list; //return [list autorelease]; if i keep this i am getting exception.
}
How to release the list and also i need the content which I am calling from view controller.
You’re getting a reported leak because the memory management guidelines say that you’re supposed to be returning an autoreleased object. In addition, you shouldn’t be prefixing your method name with “get” unless you’re planning on providing data via an out parameter.
So your method should be:
If you’re getting an exception by returning
[list autorelease], then your problem lies elsewhere (perhaps you’re releasing the array somewhere else when you shouldn’t be?).