On Thu, Apr 9, 2009 at 7:02 PM, Preston Jackson
<preston.a.jack...@gmail.com> wrote:
> Anyone have any ideas on this?

First, you typically don't bind views directly to the model.  You
instead bind them through a controller.

I did a quick test, however, in which I did bind an NSTextField
straight to my model.  I created a simple NSObject subclass with an
NSString property called "uppercaseString".  I also implemented
-validateUppercaseString:error: to always convert the string to
uppercase.  I then bound an NSTextField to this property, and turned
on "Validates Immediately."  It works like a charm.

Here is my implementation of -validateUppercaseString:error:, for reference.

- (BOOL)validateUppercaseString:(id *)newValue error:(NSError **)error
{
   if(*newValue == nil)
      return YES;
        
   *newValue = [*newValue uppercaseString];
   return YES;
}

How does your implementation differ?  Are you perhaps mutating the
*newValue instead of returning a new object, as the documentation says
you must?  
http://developer.apple.com/DOCUMENTATION/Cocoa/Conceptual/KeyValueCoding/Concepts/Validation.html#//apple_ref/doc/uid/20002173-168285

--Kyle Sluder
_______________________________________________

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