設成@property(copy)
轉化為setter:
ex:
-(void)setName:(NSString*)newName
{
NSString *temp = name;
name = [newName copyWithZone:nil];
[temp release];
}
設成@property(retain)
轉化為setter:
ex:
-(void)setName:(NSString*)newName
{
[newName retain];
[name release];
name = newName;
}
garbage collection:
當有garbage collection,在@property裡設定retain其實和assign是一樣的。
沒有留言:
張貼留言