I am a little confused about retain/release count when a local variable is allocated within a method, then returned to its caller. For example
-(NSMutableString*)foo {
NSMutableString *str = [[[NSMutableString alloc] init] autorelease];
[str appendString:@"Just a test"];
return str;
}
NSMutableString *myString = [self foo];
Questions: (as you can see I am quite confused by this case) 1. Will str retain count increment when it is assigned to myString? 2. Is it safe to autorelease in this case? 3. Who should clean up the memory?
Thanks.