• 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: Newbie Key Value-coding and Subclasses Question
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Newbie Key Value-coding and Subclasses Question


  • Subject: Re: Newbie Key Value-coding and Subclasses Question
  • From: Arturo Perez <email@hidden>
  • Date: Thu, 09 Feb 2006 11:17:33 -0500

David Avendasora wrote:
Hi.

I have a relationship from Label to Part (toOne)

Part has three subclasses: Raw, Intermediate and Finished. All of these (Part, Raw, Intermediate and Finished) are all EOGenericRecord classes right now.

I'm running into two problems

1) How do I perform an instanceof to determine what subclass of Part takeStoredValueForKey("part") returns when run on a Label object? Do I have to generate the custom classes first for Part and it's subclasses?

2) How do I call subclass-specific methods with key value-coding when the relationship is to the superclass? I have no problem executing superclass-specific methods using valueForKeyPath("part.partDescription"), but I want something along the lines of valueForKeyPath("finished.unitQuantity") (unitQuantity is an attribute of the Finished subclass of Part)

Well, instanceof in an OO design is generally considered bad practice. You may want to reconsider if your design requires it. If you really do need to know what something is I think you can do something like getting the EODescription/EOClassDescription of the EOGenericRecord and one of the attributes is the name you've given it.

What's the problem you're running into with the second thing? If you have a relationship to something and you do what you've written it should just work.

-arturo

_______________________________________________
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: Newbie Key Value-coding and Subclasses Question
      • From: David Avendasora <email@hidden>
References: 
 >Newbie Key Value-coding and Subclasses Question (From: David Avendasora <email@hidden>)

  • Prev by Date: Re: Seeking Advice for Getting Started
  • Next by Date: Re: EnterpriseObjects in a regular Java application
  • Previous by thread: Newbie Key Value-coding and Subclasses Question
  • Next by thread: Re: Newbie Key Value-coding and Subclasses Question
  • Index(es):
    • Date
    • Thread