Re: Value Transformer with multiple Model Key Paths
Re: Value Transformer with multiple Model Key Paths
- Subject: Re: Value Transformer with multiple Model Key Paths
- From: Reinhard Segeler <email@hidden>
- Date: Mon, 31 May 2010 01:49:54 +0200
Okay. I usually create a new class and copy the code (.h, .m) from
another NSConversion Class.
- (id)transformedValue:(id)value
{
// You should this code, because this assures that you are feeding the
desired NSObject - here an NSNumber and is independent from your
returned value, because your method uses (id)
if ( value == nil )
{
return @"Not defined";
}
if (![ value respondsToSelector: @selector(integerValue)] )
{
[NSException raise: NSInternalInconsistencyException
format: @"Value does not respond to -
integerValue. No idea what to do. (Value is an instance of %@).",
[value class]];
}
// this assures that you are using the desired values - end comment
// add here your code that "knows" which color to use.
// Don't forget to set up in IB the new class name for the desired
column(s)
// You must return an NSNumber object NOT the integer itself, if you
return an integer, but in your case return the NSColor, of course!
// That's all.
}
-- Reinhard
Am 31.05.2010 um 00:27 schrieb Mikael Wämundson:
- (id)transformedValue:(id)value
{
BOOL theBoolean = [value boolValue];
if (theBoolean) {
return [NSColor blueColor];
}
return [NSColor blackColor];
}
_______________________________________________
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