开发者

UITextField apply filter to display

开发者 https://www.devze.com 2022-12-15 18:05 出处:网络
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

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

精彩评论

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

关注公众号