I have an NSStepper with maxValue bound to myarr...@count, minValue fixed at 1. value bound to myArrayController selectionIndex and a PlusOneTransformer.

Works fine.

Also an NSTextField with value bound to myArrayController selectionIndex and a PlusOneTransformer.

Looks also ok.

But when I enter a number into this NSTextField reverseTransformedValue: of my PlusOneTransformer get called an infinite number of times (with the same argument) until the program crashes because at about 65000 calls the stack gets corrupted.

Here is my PlusOneTransformer:

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

+ (BOOL)allowsReverseTransformation;
{
    return YES;
}

- (id)transformedValue:(id)value;
{
        NSUInteger a = [ value unsignedIntegerValue ];
        NSNumber *dd = [ NSNumber numberWithUnsignedInteger: a + 1 ];
        return dd ;
}

- (id)reverseTransformedValue:(id)value;
{
        NSUInteger a = [ value unsignedIntegerValue ];
        if ( a > 0 ) a--;
        NSNumber *dd = [ NSNumber numberWithUnsignedInteger: a ];
        return dd ;
}

What am I doing wrong?
(Adding a number formatter to the text field did not change anything)
I also tried to bind the max value of the stepper to @count - 1 but IB told me not to use "-".

Kind regards,

Gerriet.

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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 arch...@mail-archive.com

Reply via email to