• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: NSValueTransformer problem with NSTextField update
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSValueTransformer problem with NSTextField update


  • Subject: Re: NSValueTransformer problem with NSTextField update
  • From: Quincey Morris <email@hidden>
  • Date: Thu, 1 Oct 2009 11:16:51 -0700

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 (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


  • Follow-Ups:
    • Re: NSValueTransformer problem with NSTextField update
      • From: Paul Bruneau <email@hidden>
References: 
 >Re: NSValueTransformer problem with NSTextField update (From: Paul Bruneau <email@hidden>)
 >Re: NSValueTransformer problem with NSTextField update (From: "I. Savant" <email@hidden>)
 >Re: NSValueTransformer problem with NSTextField update (From: Paul Bruneau <email@hidden>)
 >Re: NSValueTransformer problem with NSTextField update (From: "I. Savant" <email@hidden>)
 >Re: NSValueTransformer problem with NSTextField update (From: Paul Bruneau <email@hidden>)
 >Re: NSValueTransformer problem with NSTextField update (From: "I. Savant" <email@hidden>)
 >Re: NSValueTransformer problem with NSTextField update (From: Paul Bruneau <email@hidden>)

  • Prev by Date: Re: Order of CALayer's
  • Next by Date: Re: [Enigmatic semi-solution] Re: Cannot get pixel color from NSBitmapImageRep
  • Previous by thread: Re: NSValueTransformer problem with NSTextField update
  • Next by thread: Re: NSValueTransformer problem with NSTextField update
  • Index(es):
    • Date
    • Thread