On Sep 7, 2010, at 17:58, Chris Tracewell wrote:
> -(BOOL)isLessThanZero
> {
> NSNumber *theNumOne = [NSNumber numberWithInteger:0];
> NSNumber *theNumTwo = self;
>
> NSLog(@"theNumOne = %@",theNumOne);
> NSLog(@"theNumTwo = %@",theNumTwo);
> NSLog(@"NSOrderedSame = %d, NSOrderedAscending = %d,
> NSOrderedDescending =
> %d",NSOrderedSame,NSOrderedAscending,NSOrderedDescending);
> NSLog(@"SHOULD SAME = %d",[theNumTwo compare:theNumTwo]);
> NSLog(@"SHOULD ASCD = %d",[theNumOne compare:theNumTwo]);
> NSLog(@"SHOULD DESD = %d",[theNumTwo compare:theNumOne]);
>
> if ([theNumOne compare:theNumTwo] == NSOrderedDescending)
> {
> return YES;
> }
>
> return NO;
> }
The message in the 'if' ([theNumOne compare:theNumTwo]) is an invocation of
[NSNumber compare:], not [NSDecimalNumber compare:]. It's not absolutely clear
what is supposed to happen when the compare parameter is an instance of
NSDecimalNumber. Yes, NSDecimalNumber is a subclass of NSNumber, but these are
abstract classes. The actual objects are (typically) concrete subclasses of the
abstract classes, such as NSCFNumber. It's possible that this muddies the
waters enough that the mixed comparison doesn't work as you would expect.
In any case, why not simply do the comparison between 'self' and
'[NSDecimalNumber zero]'?
_______________________________________________
Cocoa-dev mailing list ([email protected])
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com
This email sent to [email protected]