我在 initWithCoder 方法中有泄漏。
unarchiveObjectWithData:cacheData 会返回一个自动释放的对象吗?谁负责释放 unarchiveObjectWithData:cacheData 返回的对象?
@implementation MyObject
@synthesize something = _something;
- (id)initWithCoder:(NSCoder *)aDecoder
{
if (self = [super init])
{
self.something = [aDecoder decodeObjectForKey:@"something"];
}
}
- (void)dealloc
{
self.something = nil;
[super dealloc];
}
@end
这是我从文件中读取对象的地方
MyObject *myObject = [NSKeyedUnarchiver unarchiveObjectWithData:cacheData];