Re: Casting (was: NSCalendarDate from plist)
Re: Casting (was: NSCalendarDate from plist)
- Subject: Re: Casting (was: NSCalendarDate from plist)
- From: Ondra Cada <email@hidden>
- Date: Sun, 25 Nov 2001 23:33:57 +0100
Erik,
>
>>>>> Erik M. Buck (EMB) wrote at Sun, 25 Nov 2001 16:31:48 -0600:
EMB> >if ([(NSString*)[a objectAtIndex:n] compare:o]<0) ....
EMB>
EMB> The problem with a cast like the above is that the programmer may not
EMB> know that [a objectAtIndex:n] is really an NSString instance.
Of course -- I presumed that it's a case when he does know. Otherwise it
would seem that isKindOfClass might be indicated ;)
EMB> -(NSComparisonResult)compare:(NSNumber *)aValue,
EMB> -(NSComparisonResult)compare:(NSDate *)aValue, and
EMB> -(NSComparisonResult)compare:(NSString *)aValue
EMB>
EMB> methods should all be changed to
EMB>
EMB> -(NSComparisonResult)compare:(id)aValue.
EMB>
EMB> For the type using versions there should be
EMB>
EMB> -(NSComparisonResult)compareNumber:(NSNumber *)aValue,
EMB> -(NSComparisonResult)compareDate:(NSDate *)aValue, and
EMB> -(NSComparisonResult)compareString:(NSString *)aValue methods.
Or perhaps "compareToXxxx:", to be conforming with "isEqualToXxxx:"? I'm not
sure -- well, English is not my native language, and I dunno whether
"compare X" or "compare to X" is more natural...
Otherwise, amen to that!
EMB> Who wants to file a bug or feature request ?
Ahem... well, who? ;)
---
Ondra Cada
OCSoftware: email@hidden
http://www.ocs.cz
2K Development: email@hidden
http://www.2kdevelopment.cz
private email@hidden
http://www.ocs.cz/oc