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 10:42:39 -0400
Fabulous, Hank! Thank you. I am actually giddy to try it out!
On Oct 10, 2007, at 10:32 AM, Hank Heijink wrote:
Hi,
I had exactly the same wish, and no, you don't have to store your
NSTimeInterval as an object. Interface Builder takes care of it for
you if you use bindings.
What you do is this: your value transformer takes an id and returns
an id. You get the time interval by calling -doubleValue on your
input argument, you convert that to minutes in any way you want,
format it into a string, and return that.
In Interface Builder, you bind the value like you did before, and
fill in the name of your value transformer in the appropriate
field. Done! (Of course, you have to register your value
transformer first, see the documentation).
Hope this helps,
Hank
On Oct 10, 2007, at 10:12 AM, Paul Bruneau wrote:
Hi-
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.
But to my newb eyes it seems to only want to transform objects (I
could be wrong).
Am I wrong, or should I do something like store my NSTimeInterval
as an NSNumber in my object and redo minimal code to make my other
stuff work with it?
I thank you
_______________________________________________
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