NSValueTransformer Loop
NSValueTransformer Loop
- Subject: NSValueTransformer Loop
- From: "Gerriet M. Denkmann" <email@hidden>
- Date: Sat, 3 Oct 2009 13:27:35 +0700
I have an NSStepper with maxValue bound to myArray.@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 (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