Stack Exchange
initWithCoder leak
I have a leak in my initWithCoder. 
Can anyone help me see what's wrong?
In my custom classes I have tried both using self. and without...
-(id) initWithCoder: (NSCoder *) decoder {  
    if( self = [super init] )
    {
        persons = [[decoder decodeObject] retain];
        title = [[decoder decodeObject] retain];
    }
    return self;
 }

-(id) initWithCoder: (NSCoder *) decoder {
    if( self = [super init] )
    {
       self.name = [decoder decodeObject];
       self.address = [decoder decodeObject];
       self.email = [decoder decodeObject];
       self.comment = [decoder decodeObject];
    }   
    return self;
}


NSData *getData = [[[NSData alloc] initWithContentsOfFile:path] autorelease];

Group = [[NSKeyedUnarchiver unarchiveObjectWithData:getData] retain];


......
......
......



[Group release];


What told oyu there was a leak? This specific code looks ok.

It is? Leaks tool report 986 NSCFStrings which is the number of objects NSData holds. Responsible Frame: [Group initWithCoder:] when I open the stack trace it shows the line self.name = [decoder decodeObject]

I don't know if this has anything to do with it, but you're using an NSKeyedUnarchiver...shouldn't you be using decodeObjectForKey:?

Are they being released in -dealloc?

Remove the retain, and post results.

removing retain crashes the app

yep, they are released

If you click the arrow next to the memory address, it will show you the retain/release/autorelease history for that address. Much more useful than just the thing that first allocated it, in my experience...
