Re: Using NSValueTransformer with a double
Re: Using NSValueTransformer with a double
- Subject: Re: Using NSValueTransformer with a double
- From: Paul Bruneau <email@hidden>
- Date: Wed, 10 Oct 2007 11:51:06 -0400
On Oct 10, 2007, at 11:32 AM, Stephen F. Booth wrote:
I have an object with an instance variable of type NSTimeInterval
which as you know is actually just a double containing number of
seconds.
I would like to bind this ivar to an NSTextField on my interface
which works fine, except that it displays in seconds of course. I
want the user to experience this value in minutes.
So I look at NSValueTransformer which seems to be made exactly for
this type of thing.
I would recommend using NSFormatter in lieu of NSValueTransformer
for this case, since you are just reformatting data for
presentation to the user. It doesn't seem to me that you actually
need to transform the value. In my experience the lines between
NSValueTransformer and NSFormatter can become blurred.
I've written an NSFormatter subclass that does what you're after;
see http://playosx.svn.sourceforge.net/viewvc/playosx/trunk/
Formatters/SecondsFormatter.m?view=markup for the source code.
OK I'll look at the docs for NSFormatter. Although Apple's example of
NSValueTransformer where they show a Celcius to Farenheight
conversion seems to me to be a nearly perfect analogy to my second to
minute needs. So if my lines are blurry, I blame Apple :)
Thanks for the link to the source code too!
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
This email sent to email@hidden