• 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: Access instance var from NSValueTransformer
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Access instance var from NSValueTransformer


  • Subject: Re: Access instance var from NSValueTransformer
  • From: mmalcolm crawford <email@hidden>
  • Date: Sun, 14 Nov 2004 15:11:05 -0800


On Nov 14, 2004, at 2:37 PM, Todd Freese wrote: (Copied back to list with permission)
There are a couple of "workarounds"; which one you choose will depend
on what work you are prepared to do...
Can you point to some of these? My first attempt at a workaround was using
some global vars. However, this was a major hack in that it would require
quite a bit of coding to support multiple open documents.


The most appropriate approach might, then, be to bind to a different property...

If you're currently binding, say, to timeCodeNumber, you could create a new pair of accessors, -timeCodeNumberWithString, and setTimeCodeNumberWithStringForDocument:, that encapsulate the value transforms.

For example, timeCodeNumberWithString would return the same as timeCodeNumber passed through the value transformer. setTimeCodeNumberWithStringForDocument would call setTimeCodeNumber:


- (void)setTimeCodeNumberWithStringForDocument:(id)value { if (value == nil) { [self setTimeCodeNumber:nil]; return; } [self setTimeCodeNumber: [TimeCodeNumber initWithString:value // * base:[self whatever] isNonDrop:[self whateverElse]]; }


(*) I'm guessing that this is a convenience constructor? If so, to follow more standard naming conventions you might consider instead 'timeCodeNumberWithString:base:isNonDrop:'.


I would *personally* (I know this is subject to some debate!) also then suggest:

	[self setTimeCodeNumber:
		[TimeCodeNumber initWithString:value // *
			base:[self whatever]
			isNonDrop:[self whateverElse]];

becomes:

	TimeCodeNumber *timeCodeNumber = [[TimeCodeNumber alloc]
		initWithString:value // *
		base:[self whatever]
		isNonDrop:[self whateverElse]];
	[self setTimeCodeNumber:timeCodeNumber];
	[timeCodeNumber release];


mmalc _______________________________________________ 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
  • Follow-Ups:
    • Re: Access instance var from NSValueTransformer
      • From: Todd Freese <email@hidden>
  • Prev by Date: Best way to catch signals in a Cocoa app
  • Next by Date: Re: New Spotlight Info
  • Previous by thread: Re: Access instance var from NSValueTransformer
  • Next by thread: Re: Access instance var from NSValueTransformer
  • Index(es):
    • Date
    • Thread