NSKeyedUnarchiver and memory management
NSKeyedUnarchiver and memory management
- Subject: NSKeyedUnarchiver and memory management
- From: DKJ <email@hidden>
- Date: Mon, 7 Sep 2009 14:53:37 -0700
I included this method in the MyObject class as part of implementing
the NSCoder protocol:
- (id)initWithCoder:(NSCoder *)aDecoder
{
self = [super init];
theData = [[aDecoder decodeObjectForKey:@"theData"] retain];
return self;
}
This is how I read the object from disk:
MyObject *myob = [NSKeyedUnarchiver unarchiveObjectWithFile:filepath];
(Garbage collection is not activated.) My understanding of the memory
management rules is that I don't need to release myob. And I get
EXC_BAD_ACCESS errors when I do.
But Instruments is complaining about a memory leak, and mentions
NSKeyedUnarchiver. The "retain" message in the initWithCoder makes me
wonder.
Is this code leaking? Should I add an autorelease to the retain in
initWithCoder?
dkj
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden