• 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: Steve Gran <email@hidden>
  • Date: Fri, 9 Dec 2005 12:45:20 -0800

That doesn't return what I want either.

I change the the line to
[returnedPrice setIntValue: [[theObjectINeed valueForKey:@"priceOfCar"] intValue]];

So now I do understand that "theObjectINeed" (because of the use of predicate) is not really "The" object but actually an array which contains the single object that matched the predicate (in this case myCar2).

But I still can't then figure out how to get the one instance variable I want from that object (in this case 'priceOfCar' from myCar2) in the form of an integer (which again is what that instance variable was declared as in the Cars Class I created.

If anyone can help with some detailed (as in the correct code I should use) example that would be great. I keep rereading the information on NSArray and NSNumber but it's a bit confusing for me because I don't really "get" the concept of how to get back instance variables of an object when the object is in an array.



>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.



>> [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?



_______________________________________________
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
  • Follow-Ups:
    • Re: Using instance variable from NSArray of objects
      • From: Andreas Mayer <email@hidden>
  • Prev by Date: Programmatically add data to a Persistent Data Model with Bindings
  • Next by Date: Re: Programmatically add data to a Persistent Data Model with Bindings
  • Previous by thread: Re: Using instance variable from NSArray of objects
  • Next by thread: Re: Using instance variable from NSArray of objects
  • Index(es):
    • Date
    • Thread