• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: NSDictionary & KVC problem
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

  • Follow-Ups:
    • Re: NSDictionary & KVC problem
      • From: Nathan Dumar <email@hidden>
References: 
 >RE: NSDictionary & KVC problem (From: <email@hidden>)
 >Re: NSDictionary & KVC problem (From: Nathan Dumar <email@hidden>)

  • Prev by Date: Re: NSDictionary & KVC problem
  • Next by Date: Re: NSDictionary & KVC problem
  • Previous by thread: Re: NSDictionary & KVC problem
  • Next by thread: Re: NSDictionary & KVC problem
  • Index(es):
    • Date
    • Thread