I have a category on NSDecimalNumber that seems very straight forward - yet is
producing odd results. The code below shows my logging and everything outputs
as expected - but the final evaluation does not work. Am I misunderstanding
something?
-(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 above NSLogs produce.....
2010-09-07 17:52:52.559 TheApp[80337:a0f] theNumOne = 0
2010-09-07 17:52:52.559 TheApp[80337:a0f] theNumTwo = 191.2
2010-09-07 17:52:52.560 TheApp[80337:a0f] NSOrderedSame = 0, NSOrderedAscending
= -1, NSOrderedDescending = 1
2010-09-07 17:52:52.560 TheApp[80337:a0f] SHOULD SAME = 0
2010-09-07 17:52:52.560 TheApp[80337:a0f] SHOULD ASCD = -1
2010-09-07 17:52:52.560 TheApp[80337:a0f] SHOULD DESD = 1
When I do the comparison from the controller instead of using the above
category it works fine. Thanks in advance for any help.
--chris_______________________________________________
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]