[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
What's wrong with this code?
From: |
Frederic |
Subject: |
What's wrong with this code? |
Date: |
Sun, 07 Jan 2001 23:49:29 +0100 |
Hi,
I can't get the following code to work. It crashes randomly around
[[aDecoder decodeObject] retain];.
I stepped into without success (It never crashes at the same place!).
Sadly, the call stack is (as too often) broken:
(gdb) where
#0 0x8067f83 in objc_msg_lookup ()
#1 0x4057ae14 in __DTOR_END__ ()
#2 0x40539fbf in _OBJC_METH_VAR_TYPE_18 ()
Cannot access memory at address 0x50000.
buggy code:
-initWithCoder:aDecoder
{
id key = nil;
id rebuiltProperties = nil;
NSEnumerator* keyEnumerator = nil;
self = [super initWithCoder:aDecoder];
_properties = [[aDecoder decodeObject] retain];
rebuiltProperties = [NSMutableDictionary
dictionaryWithCapacity:[_properties count]];
keyEnumerator = [_properties keyEnumerator];
while ( key = [keyEnumerator nextObject] )
{
[rebuiltProperties setObject:[_properties objectForKey:key]
forKey:[NSString keyWithString:key]];
/* +keyWithString is
a category that returns a
NSString which is warranted
to be uniq in the session*/
}
[_properties setDictionary:rebuiltProperties];
return self;
}
The original code, which used to work perfectly was:
-initWithCoder:aDecoder
{
id key = nil;
id rebuiltProperties = nil;
NSEnumerator* keyEnumerator = nil;
self = [super initWithCoder:aDecoder];
_properties = [[aDecoder decodeObject] retain];
return self;
}
Any idea?
Thanks, Frederic
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- What's wrong with this code?,
Frederic <=