Comparing NSDecimalNumber to NaN?
Comparing NSDecimalNumber to NaN?
- Subject: Comparing NSDecimalNumber to NaN?
- From: "Brian Barth" <email@hidden>
- Date: Thu, 28 Aug 2003 23:29:36 +0200
Hi!
This thing seems so obvious but still I don't get it.
What I want to do is simple:
I have a TableView and this standard method:
-(void)tableView: (NSTableView *) listTableView
setObjectValue: (NSString*) someText
forTableColumn: (NSTableColumn *) column
row: (int) rowIndex
We know that well.
I only want to accept numbers as input. I have a NSMutableArray of
NSDecimalNumbers as a data source.
Now to be sure the user entered some valid data, I first used a delegate
method (- (BOOL) control: (NSControl *) control
textShouldEndEditing:(NSText *) fieldEditor) which didn't seem to work as
the data seemed to be converted into my decimal number before I could get
a grip of it.
Then I wanted at least catch the error in the above mentioned
tableView:setObjectValue:forTableColumn:row: method.
Here is what I did:
NSDecimalNumber *entry = [NSDecimalNumber decimalNumberWithString: someText];
Which works fine, if I enter garbage I get a NaN.
So now my question: How do I check if I got a NaN???
I used:
if ( [entry compare: [NSDecimalNumber notANumber]] == NSOrderedSame )
if ( [entry isEqual: [NSDecimalNumber notANumber]] )
if ( [[entry description] isEqualToString: @"Nan"] )
All didn't work and the compiler complains: "warning: statement with no
effect". Right he is.
Can't be that hard, can it?
Any help appreciated!
TIA
Brian.
--
The best way to accelerate a PC is at 9.8 m/s^2.
7 7 7 b o b 7 7 7 (osXdriven) 7 7 7 www.bobthevisitor.de 7 7 7
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.