Why this kind of release doesn't work?
- by parkyprg
Hello,
I have a newbie question about the following:
- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section {
NSArray *anArray;
anArray = [dictionary objectForKey: [NSString stringWithFormat:@"%d", section]];
//here dictionary is of type NSDictionary, initialized in another place.
AnObject *obj = [[AnObject alloc] init];
obj = [anArray objectAtIndex:0];
[anArray release];
return obj.title;
}
If I run it as it is I will get an error.
If I don't put [anArray release] it works just fine.
I don't quite understand why is this happening?
Thanks.