Re: Access instance var from NSValueTransformer
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