iPhone: Return NSMutableArray in method while still releasing
问题 I am trying to understand a little more about memory management. Knowing that I need to release anything that I have init or alloc'ed I am confused about the following: - (NSMutableArray *)getData { NSMutableArray *data = [[NSMutableArray alloc] init]; NSString *first = @"First object"; [data addObject:first]; NSString *second = @"Second object"; [data addObject:second]; return data; } Since I used alloc and init, I know I need to release my data object. But if I add autorelease to the init