Text fields bound to numerical property - commas in number
Text fields bound to numerical property - commas in number
- Subject: Text fields bound to numerical property - commas in number
- From: Jonathan Taylor <email@hidden>
- Date: Wed, 18 Mar 2015 12:56:42 +0000
I've come back to some old code that I haven't used for a while, and in the meantime I've done several OS upgrades and Xcode upgrades so plenty has changed, but my code is behaving in a strange way that I'm sure it didn't used to.
I have a text field in my GUI bound to a property of type 'double'. The text field does not have any explicit number formatter attached to it. When I set the property e.g. to 22000 then it appears in the text field as:
22,000
OK, fair enough, maybe the default formatting behaviour of text fields has changed. The problem is that when I alter that value (but leaving it in the same style), so for example I change it to:
22,001
then the value of my property is set to 22. In other words, the comma is not being parsed correctly to treat the whole text string as a number.
This behaviour seems very strange and inconsistent. Is this something that people are familiar with? I imagine I could solve this by putting an explicit number formatter on every text field, but I have rather a lot of them and so would prefer not to do this! I'm also concerned that this is indicative of some subtler underlying problem that I should maybe understand rather than hide.
Can anyone advise at all?
Cheers
Jonny.
_______________________________________________
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