• 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: Can a value transformer get its own registration name?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Can a value transformer get its own registration name?


  • Subject: Re: Can a value transformer get its own registration name?
  • From: Jim Correia <email@hidden>
  • Date: Thu, 12 Apr 2007 11:46:35 -0400

On Apr 12, 2007, at 11:12 AM, Bill Cheeseman wrote:

on 2007-04-12 8:44 AM, Jim Correia at email@hidden wrote:

The same way you'd do for any other object. You write a subclass of
NSValueTransformer with per instance state. Instantiate one, and
register it.

Sure, like I suggested -- since I'm somewhat religious about accessor
methods, a -registeredName accessor to expose an iVar. I think I was just
surprised that NSValueTransformer doesn't already implement a
-registeredName mechanism, including an appropriate -initWith... Method. My
fiddling with value transformers suggests that it would be useful
frequently.


The documentation seems unusually mysterious about it. Usually, the docs
talk about subclassing when that's what they have in mind.

You have to subclass an NSValueTransformer to do useful work since the logic to do the transform is specific to your subclass.


If your transformation depends on parameters, it makes sense to store them as iVars rather than to try to determine the name that you were registered with and reconstruct the parameters on the fly based on the name.

Consider that

- a transformer does not need to be registered by name at all
- it may be instantiated directly for a particular task
- it may be set as a binding option programatically using NSValueTransformerBindingOption


- a single instance may registered under multiple names for compatibility reasons

I'm still not understanding how a transformer knowing which name(s) it was registered under helps solve the problem posed.

Jim
_______________________________________________

Cocoa-dev mailing list (email@hidden)

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: Can a value transformer get its own registration name?
      • From: Bill Cheeseman <email@hidden>
References: 
 >Re: Can a value transformer get its own registration name? (From: Bill Cheeseman <email@hidden>)

  • Prev by Date: Re: WM_KEYDOWN
  • Next by Date: RE: NSTextField Image
  • Previous by thread: Re: Can a value transformer get its own registration name?
  • Next by thread: Re: Can a value transformer get its own registration name?
  • Index(es):
    • Date
    • Thread