FROM : Miguel Arroz
DATE : Tue Nov 23 20:35:50 2004
Hi!
As some people noted, the problem was that I needed to define the
hash method for the CSCardDistanceIndex class... :-/ Some thousand
lines of code later and I'm still a Cocoa newbie!
Thanks for the help
Miguel Arroz
On 23 de nov de 2004, at 12:15, Miguel Arroz wrote:
> Hi!
>
> I saw that, but that does not mean the objects are found using
> isEqual, it just means that it uses isEqual to make sure the keys are
> not the same.
>
> My problem is that I have one key that I know it's there, but
> objectForKey does return nil. I'm doing this to test:
>
> CSCardDistanceIndex *indexx = [[[CSCardDistanceIndex alloc] init]
> autorelease];
> [indexx setCard1:card1];
> [indexx setCard2:card2];
>
> NSArray *keys = [distanceList allKeys];
> int a;
> for( a = 0; a < [keys count]; a++ ) {
> NSLog(@"-> %@", [keys objectAtIndex:a]);
> if( [indexx isEqual:[keys objectAtIndex:a]] ) {
> NSLog( @"OLA1" );
> CSCardDistance *d1 = [distanceList objectForKey:indexx];
> NSLog( @"OLA2" );
> CSCardDistance *d2 = [distanceList objectForKey:[keys
> objectAtIndex:a]];
> if( d1 == nil || d2 == nil ) {
> NSLog(@"HEY");
> }
> }
> }
>
> I have set the debugger to stop in the NSLog(@"Hey") line. When it
> stops, d1 is nil and d2 is the object i want! What is REALLY strange
> os that it stops! So, indexx isEqual to the key in the allKeys array
> (or else, the first "if" would fail) but the dictionary cannont find
> the objcect using that key.
>
> Even more amazing, I have a NSLog line on the isEqual method, and
> between OLA1 and OLA2 the isEqual method is NOT called! I am
> absolutely sure the keys are OK (i have printed the dicitionary
> description, and all the keys are CSCardDistanceIndex instances). I
> really don't know what's going on... I spent almost 5 hours trying to
> find this bug, with no luck.
>
> Yours
>
> Miguel Arroz
>
> On 23 de nov de 2004, at 3:09, Andreas Mayer wrote:
>
>>
>> Am 23.11.2004 um 03:39 Uhr schrieb Miguel Arroz:
>>
>>> A simple question... how does an NSDictionary compare the keys?
>>> Does it use isEqual, or is it just a simple comparation (using ==)?
>>
>> What about checking the documentation?
>>
>> <http://developer.apple.com/documentation/Cocoa/Reference/Foundation/
>> ObjC_classic/Classes/NSDictionary.html>
>>
>> "That is, no two keys in a single dictionary are equal (as determined
>> by isEqual:)."
>>
>>
>> Andreas
>>
>> _______________________________________________
>> MacOSX-dev mailing list
>> <email_removed>
>> http://www.omnigroup.com/mailman/listinfo/macosx-dev
>>
>>
>
> "I felt like putting a bullet between
> the eyes of every Panda that wouldn't
> scr*w to save its species." -- Fight Club
>
> Miguel Arroz - <email_removed> - http://www.guiamac.com
>
> _______________________________________________
> MacOSX-dev mailing list
> <email_removed>
> http://www.omnigroup.com/mailman/listinfo/macosx-dev
>
>
"I felt like putting a bullet between
the eyes of every Panda that wouldn't
scr*w to save its species." -- Fight Club
Miguel Arroz - <email_removed> - http://www.guiamac.com
DATE : Tue Nov 23 20:35:50 2004
Hi!
As some people noted, the problem was that I needed to define the
hash method for the CSCardDistanceIndex class... :-/ Some thousand
lines of code later and I'm still a Cocoa newbie!
Thanks for the help
Miguel Arroz
On 23 de nov de 2004, at 12:15, Miguel Arroz wrote:
> Hi!
>
> I saw that, but that does not mean the objects are found using
> isEqual, it just means that it uses isEqual to make sure the keys are
> not the same.
>
> My problem is that I have one key that I know it's there, but
> objectForKey does return nil. I'm doing this to test:
>
> CSCardDistanceIndex *indexx = [[[CSCardDistanceIndex alloc] init]
> autorelease];
> [indexx setCard1:card1];
> [indexx setCard2:card2];
>
> NSArray *keys = [distanceList allKeys];
> int a;
> for( a = 0; a < [keys count]; a++ ) {
> NSLog(@"-> %@", [keys objectAtIndex:a]);
> if( [indexx isEqual:[keys objectAtIndex:a]] ) {
> NSLog( @"OLA1" );
> CSCardDistance *d1 = [distanceList objectForKey:indexx];
> NSLog( @"OLA2" );
> CSCardDistance *d2 = [distanceList objectForKey:[keys
> objectAtIndex:a]];
> if( d1 == nil || d2 == nil ) {
> NSLog(@"HEY");
> }
> }
> }
>
> I have set the debugger to stop in the NSLog(@"Hey") line. When it
> stops, d1 is nil and d2 is the object i want! What is REALLY strange
> os that it stops! So, indexx isEqual to the key in the allKeys array
> (or else, the first "if" would fail) but the dictionary cannont find
> the objcect using that key.
>
> Even more amazing, I have a NSLog line on the isEqual method, and
> between OLA1 and OLA2 the isEqual method is NOT called! I am
> absolutely sure the keys are OK (i have printed the dicitionary
> description, and all the keys are CSCardDistanceIndex instances). I
> really don't know what's going on... I spent almost 5 hours trying to
> find this bug, with no luck.
>
> Yours
>
> Miguel Arroz
>
> On 23 de nov de 2004, at 3:09, Andreas Mayer wrote:
>
>>
>> Am 23.11.2004 um 03:39 Uhr schrieb Miguel Arroz:
>>
>>> A simple question... how does an NSDictionary compare the keys?
>>> Does it use isEqual, or is it just a simple comparation (using ==)?
>>
>> What about checking the documentation?
>>
>> <http://developer.apple.com/documentation/Cocoa/Reference/Foundation/
>> ObjC_classic/Classes/NSDictionary.html>
>>
>> "That is, no two keys in a single dictionary are equal (as determined
>> by isEqual:)."
>>
>>
>> Andreas
>>
>> _______________________________________________
>> MacOSX-dev mailing list
>> <email_removed>
>> http://www.omnigroup.com/mailman/listinfo/macosx-dev
>>
>>
>
> "I felt like putting a bullet between
> the eyes of every Panda that wouldn't
> scr*w to save its species." -- Fight Club
>
> Miguel Arroz - <email_removed> - http://www.guiamac.com
>
> _______________________________________________
> MacOSX-dev mailing list
> <email_removed>
> http://www.omnigroup.com/mailman/listinfo/macosx-dev
>
>
"I felt like putting a bullet between
the eyes of every Panda that wouldn't
scr*w to save its species." -- Fight Club
Miguel Arroz - <email_removed> - http://www.guiamac.com
| Related mails | Author | Date |
|---|---|---|
| Miguel Arroz | Nov 23, 03:39 | |
| Andreas Mayer | Nov 23, 04:09 | |
| Miguel Arroz | Nov 23, 13:15 | |
| Marcel Weiher | Nov 23, 13:43 | |
| Shawn Erickson | Nov 23, 16:13 | |
| Miguel Arroz | Nov 23, 20:35 | |
| Alberto Ricart | Nov 30, 19:20 |






Cocoa mail archive

