Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Simple Core Data Binding Question: NSTextField to Integer attribute




On Feb 22, 2008, at 12:03 AM, Chris Schmitt wrote:

I am sure this is easy and I am just missing something, but I want to bind my integer attribute to an NSTextField. The data is displayed correctly, but after I update the value in the text field and try to save the changes back to my model. I get an error saying that the update failed trying to set the integer value to a string value.

I have been searching for a while and I think I need to use a number formatter, but it would seem that there is an easier way to do this.

On a side note, what is the best way to make sure only numbers are typed into the text field?

Using a number formatter is the easiest way to accomplish both of these tasks. In Interface Builder, simply drag a NumberFormatter from the Library pane onto your text field and voila, it's formatted as a number, and it won't let the user enter anything but numbers into the text field. When you select the text field in the IB, you'll see a small $ icon which represents the NumberFormatter. Clicking on it and going to the Attributes tab in the Inspector will let you configure the formatter.
_______________________________________________


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:
http://lists.apple.com/mailman/options/cocoa-dev/email@hidden

This email sent to email@hidden
References: 
 >Simple Core Data Binding Question: NSTextField to Integer attribute (From: Chris Schmitt <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.