这条线会泄漏内存吗?请说明是或否。
Person.h
-------
NSMutableString *address;
Person.m
--------
@synthesize address;
-(id) init
{
self = [super init];
address = [[NSMutableString alloc] init];
return self;
}
-(void) funcA()
{
[address appendFormat:@"located|at|%@", @"Singapore"];
address = [[address stringByReplacingOccurrencesOfString:@"|" withString:@" "] mutableCopy];
}
-(void) dealloc
{
[address release];
[super release]
}
=address 是一个 NSMutableString,它也是一个属性。我只在 dealloc 方法上释放它。