Re: Integer as key in NSMutableDictionary
Re: Integer as key in NSMutableDictionary
- Subject: Re: Integer as key in NSMutableDictionary
- From: Ken Thomases <email@hidden>
- Date: Mon, 4 May 2009 16:00:52 -0500
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 ...}
nil]
forKey:ID];
I am getting warnings when adding integers in the array and assigning
the integer ID as a key. The code does work though
I very much doubt that, at least for the general case.
, but I am guessing
there is a better way to accomplish what I want. 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?
They are expecting more than just pointers, they are expecting
pointers to objects. You have to create an object and pass that. The
most appropriate class of object to wrap an NSInteger is an NSNumber.
See +[NSNumber numberWithInteger:].
Cheers,
Ken
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden