• 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 and static methods (was Hairy Java related question)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: KVC and static methods (was Hairy Java related question)


  • Subject: Re: KVC and static methods (was Hairy Java related question)
  • From: Ray Ackland <email@hidden>
  • Date: Sat, 25 Oct 2003 15:11:00 +1300

On Friday, Oct 24, 2003, at 12:41 Europe/Amsterdam, Ray Ackland wrote:

The problem I have is the type checking of the compiler doesn't know
about the mentioned static method, as I can't type it at this stage
because I don't know what the class will be yet. How do I get around
this?

Reflection? I would even venture that you could use KVC directly to get to your ends.

Don't know too much about reflection, but wouldn't that just tell you whether a class could do something? It wouldn't solve the problem of the compiler error?


The suggestion of KVC is one that could be the ideal answer, and it would never have occurred to me. Thanks for that suggestion. Now the question is whether it works with static methods. I have given it a try without success. Does anyone have the answer. In the meantime I have just resorted to using multiple if statements to match the class string to the method call.

Just as I finish writing this, I start to think that using an
interface may be the way. Any comments? Would that be the solution,
and what do I need to do in the calling code to get it to type check
against the interface?

Well, using a Java interface is usually a good idea, but you will need to have an object instance to get anywhere, not simply a class, as there is not such a thing as a static Java interface unfortunately... sigh...

Yeah, from what I had been reading it looked like I would have needed to instantiate a dummy object just to get the info. Not the end of the world though. Looks like Obj-C would have been an easier path :)


Ray.
_______________________________________________
webobjects-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/webobjects-dev
Do not post admin requests to the list. They will be ignored.

  • Follow-Ups:
    • Re: KVC and static methods (was Hairy Java related question)
      • From: Ben Trumbull <email@hidden>
    • Re: KVC and static methods (was Hairy Java related question)
      • From: petite_abeille <email@hidden>
  • Prev by Date: Re: Reusable Components - one last question
  • Next by Date: Re: KVC and static methods (was Hairy Java related question)
  • Previous by thread: Panther and Oracle 9 Dev Release
  • Next by thread: Re: KVC and static methods (was Hairy Java related question)
  • Index(es):
    • Date
    • Thread