有人可以告诉我需要内存管理或 stringWithFormat 是自动释放的。我查看了 Apple Developer 网站上的 NSString 类参考文档,但如果返回字符串副本或者“msg”只是指向自动释放字符串的指针,则看不到任何说明。
NSString *msg; //pointer declared in interface
- (id) init
{
//some initialization code..
//is 'msg' receiving a copy or just a pointer assign
msg = [NSString stringWithFormat: @"%@ %@", FName, LName];
}
- (void) dealloc
{
//release some vars, properties here..
[msg release]; //is this correct ????
//Or should I be only doing: msg = nil;
[super dealloc];
}