Question

I have two custom value transformers contained within my "Other Sources" folder, bound to table columns in IB, which I initialize thusly:

@implementation MyDocument

- (id)init 
{
    self = [super init];
    if (self != nil) {
        // initialization code
        [self initialiseValueTransformers];
    }

return self;

}

- (void) initialiseValueTransformers {
    MyFirstTransformer *myFirstTransformer = [[[MyFirstTransformer alloc] init] autorelease];
    [NSValueTransformer setValueTransformer:myFirstTransformer forName:@"MyFirstTransformer"];

    MySecondTransformer *mySecondTransformer = [[[MySecondTransformer alloc] init] autorelease];
    [NSValueTransformer setValueTransformer:mySecondTransformer forName:@"MySecondTransformer"];
}

And these work fine in IB with a column bound to arrangedObjects, model key path, value transformer.

My question is, I have just written a third transformer, but not initialized it in any way, I just have a the files MyThirdTransformer.h / .m. And it still works in IB..??

Why is this, and do I need to bother initializing the first two?

Était-ce utile?

La solution

You do not need to create your own instance of NSValueTransformer when used with Cocoa bindings that you make in IB.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top