Here i used auto-release for 'tempString' in the method 'test'. According to the rule, i should use "[temp retain]" in the main . But i didnt use it. still it works fine and prints the output. Then what is the need of "retain"? Can anyone pls tell me the reason? Thanks in advance.
-(NSMutableString *) test : (NSMutableString *) aString{
NSMutableString *tempString=[NSMutableString stringWithString:aString];
[tempString appendString:@" World"];
return tempString;}
int main (){
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
MemoryMgmt *memoryMgmt=[[MemoryMgmt alloc] init ];
NSMutableString *str1 =@"Hello";
NSMutableString *temp = [memoryMgmt test: str1];
NSLog(@" %@",temp);
[pool drain];
return 0;
}