• 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: KVC NSArray attribute to double[] ?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: KVC NSArray attribute to double[] ?


  • Subject: Re: KVC NSArray attribute to double[] ?
  • From: James Cicenia <email@hidden>
  • Date: Sun, 27 Aug 2006 21:08:47 -0500

Sacha -

That gives me a compiler error. I tried that too. Searched around ... I guess I just have to loop through.

- James

On Aug 27, 2006, at 8:51 PM, Sacha Michel Mallais wrote:

On Aug 27, 2006, at 6:22 PM, James Cicenia wrote:

Is there a way to use KVC to:

1) Given an array of EOs
2) Get an array of attribute A1 which is a double.

Not directly.


I was hoping to do:

double[] y = (double[])projects.valueForKeyPath ("calculatedRewardScore");

but this throws an exception.

What am I doing wrong?

valueForKey (and valueForKeyPath) on an NSArray return an NSArray (unless using an aggregate function like @sum, in which case they return a Double IIRC). What you want is (warning, untested code):


double[] y = (double[])((NSArray)projects.valueForKeyPath ("calculatedRewardScore")).objects();


sacha


-- Sacha Michel Mallais 400 kg chimp Global Village Consulting Inc. http://www.global-village.net/ PGP Key ID: 7D757B65 AIM: smallais "Choke on that, causality!" -- the Professor, "Futurama"



_______________________________________________ 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: KVC NSArray attribute to double[] ?
      • From: Peter Vandoros <email@hidden>
References: 
 >KVC NSArray attribute to double[] ? (From: James Cicenia <email@hidden>)
 >Re: KVC NSArray attribute to double[] ? (From: Sacha Michel Mallais <email@hidden>)

  • Prev by Date: Re: KVC NSArray attribute to double[] ?
  • Next by Date: Re: KVC NSArray attribute to double[] ?
  • Previous by thread: Re: KVC NSArray attribute to double[] ?
  • Next by thread: Re: KVC NSArray attribute to double[] ?
  • Index(es):
    • Date
    • Thread