Re: shouldn't polymorphism work here?
Re: shouldn't polymorphism work here?
- Subject: Re: shouldn't polymorphism work here?
- From: Ondra Cada <email@hidden>
- Date: Mon, 28 Mar 2005 12:49:09 +0200
Conrad,
On 28.3.2005, at 8:05, Conrad Carlen wrote:
When compiling this, I get the warnings:
/Users/<snip>/NSArray+Extensions.m:46: warning: multiple declarations
for method `compare:'
/System/Library/Frameworks/Foundation.framework/Headers/NSValue.h:53:
warning: using `-(NSComparisonResult)compare:(NSNumber *)otherNumber'
/System/Library/Frameworks/Foundation.framework/Headers/NSDate.h:29:
warning: also found `-(NSComparisonResult)compare:(NSDate *)other'
/System/Library/Frameworks/Foundation.framework/Headers/NSString.h:74:
warning: also found `-(NSComparisonResult)compare:(NSString *)string'
Now, as long as these objects implement compare:, shouldn't
polymorphism take care of calling the right one?
It should and it actually does.
The only problem is compile-time, caused by wrong declarations --
instead of declared "compare:(NSNumber*)otherNumber" etc it should have
been declared "compare:(id)otherObject" in all headers of all classes.
Runtime, it is completely all right.
---
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