Please clarify the following thing.
Everyone knows that; if we are using alloc
, retain
, new
and etc...
, we have to release it. For remaining things, we have to use autorelease
. My doubt is;
-(NSArray*)getArray{ NSArray *array = [[NSArray alloc] initWithObjects:@"1", @"2", @"3", @"4", @"5", nil]; return [array autorelease]; }
NSArray *arr = [self getArray]; --- ---
What we have to do the arr
?
EDIT:
NSString *str = [NSString stringWithFormat:@"Welcome..."];
If we are using the above statement, we should call autorelease
. But I want to know, what is happening in the stringWithFormat:
method. How it is returning NSString
.
Thanks.