Re: NSDictionary & KVC problem
Re: NSDictionary & KVC problem
- Subject: Re: NSDictionary & KVC problem
- From: Ben Ketteridge <email@hidden>
- Date: Mon, 25 Oct 2004 14:23:07 +0100
On Mon, 25 Oct 2004 09:12:44 -0400, Nathan Dumar <email@hidden> wrote:
> Art and Pierre,
>
> Sorry, I should have explained better. thisUser.preferences() returns
> an array of Preference objects, each of which has a "name" and a
> "value" field (both Strings). So
> thisUser.preferences().valueForKey("value") should return an array of
> Strings (right?), one for each of the objects (of which there are 6).
> The same for the value attribute.
>
> The results were identical when I used:
>
> prefs = new NSDictionary(new
> NSArray(thisUser.preferences().valueForKey("value")), new
> NSArray(thisUser.preferences().valueForKey("name")));
>
> or
>
> NSArray values = new
> NSArray(thisUser.preferences().valueForKey("value"));
> NSArray names = new NSArray(thisUser.preferences().valueForKey("name"));
> prefs = new NSDictionary(values, names);
>
> For some reason I end up with (I think) an NSDictionary with one array
> key and one array value instead of 6 string keys and 6 string values.
> The docs say that the constructor is supposed to go one-by-one through
> each array, adding each item to the dictionary.
The critical thing your missing is this:
prefs = new NSDictionary(
(NSArray)thisUser.preferences().valueForKey("value"),
(NSArray)thisUser.preferences().valueForKey("name")
);
Hope that fixes it,
Ben
--
| Ben Ketteridge email@hidden, aka Gremlin |
| It is by caffeine alone that I set my mind in motion. |
| It is by the coffee that the thoughts acquire speed, |
| the lips acquire stains, the stains become a warning. |
| It is by caffeine alone that I set my mind in motion. |
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden