On Oct 1, 2009, at 10:45, Paul Bruneau wrote:

// this method will cause the field to get updated upon pressing Return
-(BOOL)validateTopClearance:(id *)ioValue
                                          error:(NSError **)outError
{
   if (*ioValue == nil) {
       return YES;
   }
        //add 1 to my number just to force it to update as a test       
NSNumber * newValue = [NSNumber numberWithInteger:[*ioValue integerValue] + 1];
        *ioValue = newValue;
        
   return YES;
}

So apparently, the validator is noticing if I alter the value, and it does nothing (to my eyes) if the value is untouched. I am back at the beginning :)

What was the number you tried this with? Some NSNumber values are singleton objects, so returning a "new" NSNumber with the same value might really return the original object. :) Or maybe just equality of value matters.

It occurs to me that the singleton-ness of the underlying NSNumber objects may have something to do with why the text fields didn't behave as you expected to begin with. Or the equality.

Maybe the lesson of all of this is that using a value transformer to control formatting (that is, when the transformed string has a preferred but not unique form) is not such a good idea.

I can't remember now -- was there a reason why a NSFormatter subclass wasn't a viable option instead of a value transformer?

The other way to approach this is to add a second set of properties -- the formatted string values of your numeric properties -- that are dependent on the numeric ones, and bind to the string properties instead. It's a PITA to code it all, but it puts the formatting all in your hands.


_______________________________________________

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