I have some UITextField
s for entering currency amounts that display a number pad. In my textFieldDidEndEditing:
method I apply a currency nsnumberformatter to the tex开发者_Go百科tField.text
and update it to display as a currency value.
The problem I run into is that once I apply the currency formatter to the inputted number and update the text property, I can't call [textField.text floatValue]
any more.
I've thought about using the tag
property of the UITextField
s to hold their "actual" value, but I'm wondering if there's a better way to do this.
Ideas?
Why not store it in another float
? (as a global variable, or an ivar of the subclass, whatever)
The tag property only holds an integer, so I doubt you really can do that. You can either hold it in an instance variable, as a part of an array, or whatever.
Use a dictionary, where key is currency identifier and data is a object containing formatted currency value, actual value and some other possibly needed data.
精彩评论