• 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: shouldn't polymorphism work here?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: shouldn't polymorphism work here?


  • Subject: Re: shouldn't polymorphism work here?
  • From: Ondra Cada <email@hidden>
  • Date: Mon, 28 Mar 2005 12:55:51 +0200

Oh, sorry, I forgot:

On 28.3.2005, at 8:05, Conrad Carlen wrote:

Is there anything I can do make it more clear to the compiler and to avoid this warning?

Sure: cast middleValue to a concrete class, like

if ([(NSString*)middleVal compare:item]<0) { // can be actually anything, cast just gets rid of warning caused by wrong declarations

Note this does not change *anything* for the runtime. It just makes the compiler think middleVal is always an NSString, so that it won't complain; runtime the polymorphism *does* take care properly whatever class middleVal actually belongs to.

This techique is completely safe far as the messages differ this way only (should they have arguments -- or return values -- of non-object data, like structs, floats or so, it would be a problem).
---
Ondra Čada
OCSoftware: email@hidden http://www.ocs.cz
private email@hidden http://www.ocs.cz/oc


_______________________________________________
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: 
 >shouldn't polymorphism work here? (From: Conrad Carlen <email@hidden>)

  • Prev by Date: Re: shouldn't polymorphism work here?
  • Next by Date: RE: Creating controls dynamically
  • Previous by thread: Re: shouldn't polymorphism work here?
  • Next by thread: NSHomeDirectory() vs. -stringByExpandingTildeInPath
  • Index(es):
    • Date
    • Thread