开发者

UITextField apply filter to display

I have some UITextFields 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 UITextFields 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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜