I’m getting a leak in initWithCoder method.
Does unarchiveObjectWithData:cacheData return me an autoreleased object? whose responsible to release the object return from 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
This is where i read the object from file
MyObject *myObject = [NSKeyedUnarchiver unarchiveObjectWithData:cacheData];
Just remember NARC. If the method you are calling begins with
new,alloc,retain, orcopy, then you own any object that is returned and have to release it. If it doesn’t, then it is autoreleased.