Re: Integer as key in NSMutableDictionary

2009-05-06 Thread Marcel Weiher
Hi Greg, hope the runtime is being docile. :-) On May 4, 2009, at 23:24 , Greg Parker wrote: That's right. In some discussions of object-oriented programming, a distinction is made between "value objects" and "reference objects". Two value objects can be "equal" if they share the same "valu

Re: Integer as key in NSMutableDictionary

2009-05-05 Thread Weydson Lima
Wow, I'm learning a lot from this list. Thanks all for everything, now my code is finally working as I had wanted. :) Weydson ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Con

Re: Integer as key in NSMutableDictionary

2009-05-04 Thread Greg Parker
That's right. In some discussions of object-oriented programming, a distinction is made between "value objects" and "reference objects". Two value objects can be "equal" if they share the same "value", even if they are separately allocated objects with different pointer addresses in memory.

Re: Integer as key in NSMutableDictionary

2009-05-04 Thread Nick Zitzmann
On May 4, 2009, at 11:52 PM, Weydson Lima wrote: when I use the removeObjectForKey, how can I make a reference to a specific key? Let's say I want to remove key that was initialized with [NSNumber numberWithInt:1]. If I call removeObjectForKey:[NSNumber numberWithInt:1], that method won't

Re: Integer as key in NSMutableDictionary

2009-05-04 Thread Jonathan Hess
Hey Weydson - NSDictionary equates keys by using -[NSObject isEqual:] and -[NSObject hash], so a number with a different pointer address but the same value as determined by isEqual: is fine. If identity vs value does become an important distinction for you, CFDictionary gives you control

Re: Integer as key in NSMutableDictionary

2009-05-04 Thread Weydson Lima
Thanks all for the replies. I clearly understand now that I should use NSNumber instead of NSInteger. However, another question came up: when I use the removeObjectForKey, how can I make a reference to a specific key? Let's say I want to remove key that was initialized with [NSNumber numberWithInt:

Re: Integer as key in NSMutableDictionary

2009-05-04 Thread Jean-Daniel Dupas
Le 4 mai 09 à 22:58, Alexander Heinz a écrit : On May 4, 2009, at 3:22 AM, Weydson Lima wrote: I know that these methods are expecting pointers as parameters and I am passing a scalar. So, what's the best way to approach that? That's correct. You really shouldn't put any scalar types in an

Re: Integer as key in NSMutableDictionary

2009-05-04 Thread Martin Wierschin
Assume that: NSMutableDictionary *result = [[NSMutableDictionary alloc] initWithCapacity:10]; NSInteger ID; And I add objects to the dictionary: [result setObject:[NSArray arrayWithObjects: {... objects ...} nil]

Re: Integer as key in NSMutableDictionary

2009-05-04 Thread Ken Thomases
On May 4, 2009, at 2:22 AM, Weydson Lima wrote: NSMutableDictionary *result = [[NSMutableDictionary alloc] initWithCapacity:10]; NSInteger ID; And I add objects to the dictionary: [result setObject:[NSArray arrayWithObjects: {... objects ...}

Re: Integer as key in NSMutableDictionary

2009-05-04 Thread Alexander Heinz
On May 4, 2009, at 3:22 AM, Weydson Lima wrote: I know that these methods are expecting pointers as parameters and I am passing a scalar. So, what's the best way to approach that? That's correct. You really shouldn't put any scalar types in an NSDictionary (or any other container type in the

Re: Integer as key in NSMutableDictionary

2009-05-04 Thread Nick Zitzmann
On May 4, 2009, at 1:22 AM, Weydson Lima wrote: I am getting warnings when adding integers in the array and assigning the integer ID as a key. The code does work though, but I am guessing there is a better way to accomplish what I want. I know that these methods are expecting pointers as parame

Re: Integer as key in NSMutableDictionary

2009-05-04 Thread Jason Foreman
On May 4, 2009, at 2:22 AM, Weydson Lima wrote: I am getting warnings when adding integers in the array and assigning the integer ID as a key. The code does work though, but I am guessing there is a better way to accomplish what I want. I know that these methods are expecting pointers as paramet

Integer as key in NSMutableDictionary

2009-05-04 Thread Weydson Lima
Hi, Assume that: NSMutableDictionary *result = [[NSMutableDictionary alloc] initWithCapacity:10]; NSInteger ID; And I add objects to the dictionary: [result setObject:[NSArray arrayWithObjects: {... objects ...}