NSTableView, NSNumberFormatter, and other fun.
NSTableView, NSNumberFormatter, and other fun.
- Subject: NSTableView, NSNumberFormatter, and other fun.
- From: Greg Anderson <email@hidden>
- Date: Thu, 24 Jan 2002 21:56:03 -0600
Being relatively new to Cocoa (Obj-C, to be specific), hopefully
these aren't obvious questions.
I've got an NSTableView that has a column of temperatures as the 2nd
column. I'd like to be able to format the data in this column to a
certain number of decimal places, which sounds like the job of an
NSNumberFormatter. I can't seem to find a way to specify this via
Interface Builder. Am I missing something, or is this done
programmatically-only (or to reveal even more ignorance on my part, is it
possible)?
In a possibly related thread, I have a couple of functions in my
dataSource for the table view that iterate over the data and return the
max and min temperatures. It works fine until I change a value in the
table (via typing into a cell in the Temperature column). Then my
comparison stops working at this line:
if ([maxTemp compare:testNumber] == NSOrderedAscending) {
Where maxTemp is an NSNumber* and testNumber is an NSNumber* that I
get from
testNumber = [theRecord objectForKey:@"Temp"];
and theRecord is an NSDictionary pulled from an NSMutableArray, the
kind of stuff one expects when working with the data for a table view.
The error I'm getting reported is
-[NSCFString objCType]: selector not recognized
I'm assuming that this is because when I get testNumber, it's an
NSString, and NSString doesn't understand -compare ... maybe ... ?
I'm getting around it by comparing the [maxTemp floatValue] to
[testNumber floatValue], but that seems awfully kludgey. So I'm not sure
if I'm missing something obvious in the world of Obj-C, or if I'm missing
the way to make sure that values entered into a cell in a table view are
of the type I want them to be.
Any help is greatly appreciated. TIA.
Greg