Re: responding to NSStepper clicks
Re: responding to NSStepper clicks
- Subject: Re: responding to NSStepper clicks
- From: Mike Abdullah <email@hidden>
- Date: Sun, 18 Dec 2011 12:41:39 +0000
On 17 Dec 2011, at 11:29, Koen van der Drift wrote:
>
> On Dec 16, 2011, at 11:48 PM, Quincey Morris wrote:
>
>> There are various solutions you might choose, depending on how you expect to handle validation errors for your text field. You can add a number formatter to the field, or you can change the property to type long long (though you then need to check for negative numbers yourself), or you can use KVC validation to substitute a NSNumber object for the NSString object.
>
>
> Changing the value from NSInteger to NSNumber in my model did the trick, I don't get the crash anymore, and everything updates accordingly. I don't have to use a formatter either, although I probably need to add anyway to prevent the user from typing anything else but numbers.
You *have* to use a number formatter. What you've probably got a present is the text field sending NSString objects down into the model. You're not seeing an immediate problem because NSNumber is an object just like NSString, and so can be stored, but will completely fail as soon as something tries to work with it.
>
> The only that does't work yet is that I need to hit enter or tab to have my model respond to a change in the NSTextField. As suggested earlier, I set the binding "Continuously Update Value", but that doesn't work.
That option definitely works since we are using it!
>
> I also see a small exclamation mark (white on a red circle), in the Model Key Path bindings field, where I bind to my model. Xcode autocompletes the correct property, so I'm not sure what to do with this, since everything works. I don't see that exclamation mark in the NSStepper bindings field.
Put a formatter in and see what happens.
_______________________________________________
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