Re: Using instance variable from NSArray of objects
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