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 protected])

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [email protected]

Reply via email to