• 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
Re: Using NSValueTransformer with a double
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Using NSValueTransformer with a double


  • Subject: Re: Using NSValueTransformer with a double
  • From: Hank Heijink <email@hidden>
  • Date: Wed, 10 Oct 2007 10:32:32 -0400

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:
40runbox.com


This email sent to email@hidden


Hank Heijink email@hidden



_______________________________________________

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


  • Follow-Ups:
    • Re: Using NSValueTransformer with a double
      • From: Paul Bruneau <email@hidden>
References: 
 >Using NSValueTransformer with a double (From: Paul Bruneau <email@hidden>)

  • Prev by Date: Re: NSAutoreleasePool and static data member constructors
  • Next by Date: Re: Using NSValueTransformer with a double
  • Previous by thread: Using NSValueTransformer with a double
  • Next by thread: Re: Using NSValueTransformer with a double
  • Index(es):
    • Date
    • Thread