Re: allKeys and allValues
Re: allKeys and allValues
- Subject: Re: allKeys and allValues
- From: Nick Zitzmann <email@hidden>
- Date: Mon, 4 Oct 2010 15:30:48 -0600
On Oct 4, 2010, at 3:21 PM, gMail.com wrote:
> On the docs I read that for both the NSDictionary's allKeys and allValues,
> the order of the elements in the array is not defined. Ok.
> But, are the two arrays aligned each other?
>
> I mean, I have a dictionary containing several entries whose key is, e.g.
> @"0", @"3", @"42",...
> I show these entries on a tableView picking the dict from the rowIndex.
> aDict = [[dicts allValues] objectAtIndex:row];
> It works. But now, If I delete a row, using the rowIndex, I should do
>
> NSString *ID = [[dicts allKeys] objectAtIndex:row];
> [dicts removeObjectForKey:ID];
>
> Is that correct?
> Is it assured that the n key of the allKeys array always corresponds to the
> n value in the allValues array?
If that works, it's an implementation detail, and I wouldn't rely on that behavior because it could change at any time. You should use an array of dictionaries in a table view, not an enumerated dictionary.
Nick Zitzmann
<http://www.chronosnet.com/>
_______________________________________________
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