• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
NSTableView, NSNumberFormatter, and other fun.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Follow-Ups:
    • Re: NSTableView, NSNumberFormatter, and other fun.
      • From: Chris Giordano (at glue) <email@hidden>
    • Re: NSTableView, NSNumberFormatter, and other fun.
      • From: Ondra Cada <email@hidden>
  • Prev by Date: Subclassing NSDocumentController
  • Next by Date: Putting window titlebar under menu
  • Previous by thread: Re: Subclassing NSDocumentController
  • Next by thread: Re: NSTableView, NSNumberFormatter, and other fun.
  • Index(es):
    • Date
    • Thread