Re: NumberFormatters and sci notation
Re: NumberFormatters and sci notation
- Subject: Re: NumberFormatters and sci notation
- From: Graham J Lee <email@hidden>
- Date: Wed, 18 Jan 2006 15:29:33 +0000
On 18 Jan 2006, at 15:17, Greg Titus wrote:
On Jan 18, 2006, at 7:00 AM, Graham J Lee wrote:
BTW I'm instantiating and attaching the formatter in my NSDocument
subclass' -init method, as the text fields are outlets of that class.
Ah, there's your problem. When the document subclass -init is
called, the nib hasn't yet been loaded, so the outlets aren't yet
setup. So you are attaching the formatter to nil. Try moving the
instantiation and attachment to the -awakeFromNib method.
Cool, thanks. Now we're getting somewhere, but still not to the
end. It seems like I'm getting either/or behaviour - if I call -
setFormat: then it ignores the formatterBehavior (which means it
loses the mantissa/exponent display, and rounds most small numbers to
0.00). Conversely if I don't call -setFormat: I get the correct
behaviour but not the correct precision. What I want (got to hate
these demanding users ;-) is both. I've also tried this:
[fmt setNumberStyle:NSNumberFormatterScientificStyle];
[fmt setFormatWidth:5];
but it looks like formatWidth is only used in conjunction with
format, not formatterBehavior. So I'm still not achieving my goal
(which would be the POSIX-ish "%8.3g" or something similar). Any
other things to try?
Cheers,
Graham.
--
Graham Lee GPG Key ID: 01D5B9D8
UNIX Systems Manager,
Oxford Physics Practical Course
http://users.ox.ac.uk/~wadh1342 01865 273450
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden