NSDictionary changed?
NSDictionary changed?
- Subject: NSDictionary changed?
- From: Daniel Hazelbaker <email@hidden>
- Date: Sun, 02 Nov 2003 17:15:13 -0800
Greetings all. I am having an issue that is driving me nuts. I have an
application that worked fine under 10.2, the 10.2 binary even worked fine
under 10.3. When I recompiled under 10.3 it no longer works. Actually it
does work, sometimes, but is sporadic. Here is the basic of what I am
doing. I apologize, it is a bit confusing to read but I am hoping somebody
will notice something I did wrong and say, "oh hey do this." (Crosses
fingers)
I have an NSObject subclass called BMGroup, which is used as a key in
NS(Mutable)Dictionary:
@interface BMGroup : NSObject <NSCopying, BMCacheItem> {
NSNumber *_id;
NSString *_name;
[...]
}
- (id)copyWithZone:(NSZone *)zone
{
BMGroup *copy = [[[self class] allocWithZone: zone] init];
copy->_id = [_id copy];
copy->_name = [_name copy];
return copy;
}
- (BOOL)isEqual:(id)anObject
{
NSLog(@"checking group...");
if ([anObject isKindOfClass:[BMGroup class]] == NO)
return NO;
if ([[anObject getID] isEqual:_id] == NO)
return NO;
if ([[anObject name] isEqual:_name] == NO)
return NO;
NSLog(@"Group is equal");
return YES;
}
The following log is generated by these few lines of code:
list = [_uservalues[aType] objectForKey:aKey];
if (list == nil) {
NSLog(@"Creating list and adding to uservalues with key: %@", aKey);
list = [NSMutableArray arrayWithCapacity:1];
[_uservalues[aType] setObject:list forKey:aKey];
NSLog(@"Added list 0xX; quick find: 0xX; real find: 0xX",
list,
[_uservalues[aType] objectForKey:aKey],
[_uservalues[aType] objectForKey:[BMGroup groupFromID:[aKey getID]]]);
}
The log below is from two consecutive runs. I ran, quit, ran again and got
the different results. Has anybody else seen this behavior or know what
might be causing this sporadic behavior? I *'d the lines that are most
obvious. The first attempt to add the list to the dictionary works fine, it
calls the isEqual: method (as shown by the "checking group...Group is equal"
lines). The second run it seems like it never calls isEqual: as those two
lines are not logged. And yes, I am positive it actually added, I have
stepped through and used gdb to examine the contents of the dictionary and
it is actually in there.
Daniel Hazelbaker
(Cropped off everything before the PID so it will stuff will not line-wrap)
[RUN 1]
[Snipped a bunch of the following two lines]
[8955] checking group...
[8955] Group is equal
*[8955] Creating list and adding to uservalues with key: <BMGroup: 0x5381d0>
*[8955] checking group...
*[8955] Group is equal
*[8955] checking group...
*[8955] Group is equal
*[8955] Added list 0x005D6CD0; quick find: 0x005D6CD0; real find: 0x005D6CD0
[8955] checking group...
[8955] Group is equal
[8955] value added: None value found: None
[8955] checking group...
[8955] Group is equal
[8955] checking group...
[8955] Group is equal
[8955] value added: value found:
[8955] checking group...
[8955] Group is equal
[8955] checking group...
[8955] Group is equal
[8955] value added: value found:
[8955] checking group...
[8955] Group is equal
[8955] checking group...
[8955] Group is equal
[8955] value added: value found:
[8955] Creating list and adding to uservalues with key: <BMGroup: 0x541b30>
[8955] Added list 0x005D08A0; quick find: 0x00000000; real find: 0x00000000
[8955] value added: Tim Wheeler value found: (null)
[RUN 2]
[Snip a bunch of the following two lines]
[8965] checking group...
[8965] Group is equal
*[8965] Creating list and adding to uservalues with key: <BMGroup: 0x5381f0>
*[8965] Added list 0x005D6470; quick find: 0x00000000; real find: 0x00000000
[8965] value added: None value found: (null)
[8965] Creating list and adding to uservalues with key: <BMGroup: 0x5381f0>
[8965] checking group...
[8965] Group is equal
[8965] checking group...
[8965] Group is equal
[8965] Added list 0x005D6750; quick find: 0x005D6750; real find: 0x005D6750
[8965] checking group...
[8965] Group is equal
[8965] value added: value found:
[8965] checking group...
[8965] Group is equal
[8965] checking group...
[8965] Group is equal
[8965] value added: value found:
[8965] checking group...
[8965] Group is equal
[8965] checking group...
[8965] Group is equal
[8965] value added: value found:
[8965] checking group...
[8965] Creating list and adding to uservalues with key: <BMGroup: 0x541b50>
[8965] checking group...
[8965] checking group...
[8965] Added list 0x005D6B70; quick find: 0x00000000; real find: 0x00000000
[8965] checking group...
[8965] value added: Tim Wheeler value found: (null)
_______________________________________________
xcode-users mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/xcode-users
Do not post admin requests to the list. They will be ignored.