Re: Working with nil values [was Custom bindings in a control/cell pair]
Re: Working with nil values [was Custom bindings in a control/cell pair]
- Subject: Re: Working with nil values [was Custom bindings in a control/cell pair]
- From: Ricky Sharp <email@hidden>
- Date: Thu, 24 Feb 2005 13:16:33 -0600
On Thursday, February 24, 2005, at 12:40PM, Ricky Sharp <email@hidden> wrote:
>Any best practices for handling nil?
One other solution I came up with (and it does work) is to provide an override to setValue:forKey:
- (void)setValue:(id)aValue forKey:(NSString*)aKey
{
if (aValue == nil)
{
if ([aKey isEqualToString:@"enabledTextColor"])
{
[super setValue:[NSColor blackColor] forKey:aKey];
}
else
{
[super setValue:aValue forKey:aKey];
}
}
else
{
[super setValue:aValue forKey:aKey];
}
}
I wouldn't have to change accessor patterns, any code calling accessors or even specify value transformers (assuming they'd work in IB in the future) for all my controls. This seems like a good candidate in that I just need it implemted in each class. From reading the docs, this also seems perfectly legal to do.
--
Rick Sharp
Instant Interactive(tm)
_______________________________________________
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