Hi Siegfried-

Consider making an NSValueTransformer subclass that converts the stored integer 
into the text you would like to see.  You can then use the transformer in the 
binding to see the text you'd like.  I implemented something similar as follows:

@implementation PKConnectionStateValueTransformer

+ (Class)transformedValueClass
{
    return [NSString class];
}

+ (BOOL)allowsReverseTransformation
{
    return NO;
}

- (id)transformedValue:(id)value
{
    if([value respondsToSelector:@selector(integerValue)]){
        NSInteger thisValue = [value integerValue];
        
        switch (thisValue) {
            case PSMGameNodeStateAvailable:
                return @"Available";
                break;
                
            case PSMGameNodeStateUnavailable:
                return @"Unavavilable";
                break;
                
            case PSMGameNodeStateConnected:
                return @"Connected";
                break;
                
            case PSMGameNodeStateDisconnected:
                return @"Disconnected";
                break;
                
            case PSMGameNodeStateConnecting:
                return @"Connecting";
                break;
            default:
                break;
        }
    }
    
    return @"";
}

@end

Hope this helps!

John

Positive Spin Media
http://www.positivespinmedia.com

On Dec 29, 2010, at 12:19 PM, Siegfried wrote:

> Hello,
> 
> I have an entity which has an integer property that represents a "mode". In 
> code, I created an enum with possible values, but now I need to bind a label 
> to that property. Obviously, it's not intent to show the number, but a text. 
> What's the best way to do this? Create a dictionary, or an array of strings?
> 
> Thanks!
> 
> Siegfried_______________________________________________
> 

_______________________________________________

Cocoa-dev mailing list ([email protected])

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [email protected]

Reply via email to