Re: Solved [Q] Why unsolicited dealloc in NSKeyedUnarchiver?
Re: Solved [Q] Why unsolicited dealloc in NSKeyedUnarchiver?
- Subject: Re: Solved [Q] Why unsolicited dealloc in NSKeyedUnarchiver?
- From: "Peter.Teeson" <email@hidden>
- Date: Tue, 20 Apr 2004 19:32:44 -0400
With the help of someone in a newsgroup I have solved htis (as well as
gained a mite more understanding.
I modified this method to release and retain (as was hinted by two
gentle persons)
-(id)initWithCoder:(NSCoder *)coder {
self = [super init];
passwordRecs = [[NSMutableArray alloc] init];
[self addPasswordRecord];
if ([coder allowsKeyedCoding]) {
[passwordRecs release]; // avoid leak
passwordRecs = [coder decodeObjectForKey:@"passwordRecs"];
[passwordRecs retain]; // retain auto-released object
}
return self;
}
On Apr 20, 2004, at 15:53, Shawn Erickson wrote:
>
What is going wrong? The stack trace doesn't explain that...
>
>
-Shawn
>
>
On Apr 20, 2004, at 11:44 AM, Peter.Teeson wrote:
>
>
> Thanks for your comment. I tried your suggestion to no avail.
>
> Furthermore it is indeed NSKeyedUnArchiver that is calling dealloc as
>
> per the stack (see below).
>
> I am quite willing to admit that I am not handling memory correctly.
>
> However I still do not see where that is the case - probably because
>
> of my newbie ignorance.
>
> Please be patient with me....
>
>
>
> respect....
>
>
>
> Peter
>
>
>
> From debugger
>
> #0 0x020e8450 in -[PasswordRecord dealloc] at
>
> PasswordRecordsModel.m:88
>
> #1 0x90197fe8 in CFDictionaryRemoveAllValues
>
> #2 0x901a6088 in __CFDictionaryDeallocate
>
> #3 0x90190db0 in CFRelease
>
> #4 0x90a5545c in -[NSKeyedUnarchiver dealloc] <<<< unsolicited call
>
> #5 0x90aacf3c in +[NSKeyedUnarchiver unarchiveObjectWithData:]
>
> #6 0x02009348 in -[MyDocument loadDataRepresentation:ofType:] at
>
> .........
>
>
>
> On Apr 20, 2004, at 01:57, Louis C. Sacha wrote:
>
>
>
>> Hello...
>
>>
>
>> Actually, I don't think it is a problem with NSKeyedUnarchiver at
>
>> all. You probably just need to retain the unarchived object in your
>
>> loadDataRepresentation:ofType: method... (and check to make sure you
>
>> release it in your document's dealloc method).
>
>>
>
>> passwordRecords = [[NSKeyedUnarchiver unarchiveObjectWithData:data]
>
>> retain];
>
>>
>
>>
>
>> Hope that helps,
>
>>
>
>> Louis
>
> _______________________________________________
>
> cocoa-dev mailing list | email@hidden
>
> Help/Unsubscribe/Archives:
>
> http://www.lists.apple.com/mailman/listinfo/cocoa-dev
>
> Do not post admin requests to the list. They will be ignored.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.