• 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: Using instance variable from NSArray of objects
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Using instance variable from NSArray of objects


  • Subject: Re: Using instance variable from NSArray of objects
  • From: Andreas Mayer <email@hidden>
  • Date: Fri, 9 Dec 2005 09:57:01 +0100


Am 09.12.2005 um 09:26 Uhr schrieb Steve Gran:

theObjectINeed = [myArrayOfCars filteredArrayUsingPredicate:predicate];

And yes, sure enough, theObjectINeed is myCar2

No, it's not.

From the documentation:

"filteredArrayUsingPredicate:

Evaluates the predicate against the receiver’s content and returns a new array containing the objects that match."

So it's an NSArray.

But then when I try the following:
returnedPrice = [theObjectINeed valueForKey:@"priceOfCar"];

Of course not. NSArray does not respond to 'priceOfCar'.

[returnedPrice setIntValue: [theObjectINeed valueForKey:@"priceOfCar"]];

I get a Warning Message that says "makes integer from pointer without a cast". But the priceOfCar instance variable is an int and was declared as such. What am I doing wrong?

valueForKey: always returns an object. In case of an instance variable declared as int you will get an object of class NSNumber. Use the appropriate NSNumber methods to convert it to the type of your choice.

I'm a real Newbie

Just keep trying - and reading the docs. ;-)


Andreas _______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden
References: 
 >Using instance variable from NSArray of objects (From: Steve Gran <email@hidden>)

  • Prev by Date: Using instance variable from NSArray of objects
  • Next by Date: How To: NSAttributedString in a NSTableView, catch clicks on a link
  • Previous by thread: Using instance variable from NSArray of objects
  • Next by thread: Re: Using instance variable from NSArray of objects
  • Index(es):
    • Date
    • Thread