views:

112

answers:

3

I have some UITextFields for entering currency amounts that display a number pad. In my textFieldDidEndEditing: method I apply a currency nsnumberformatter to the textField.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?

A: 

Why not store it in another float? (as a global variable, or an ivar of the subclass, whatever)

KennyTM
A: 

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.

futureelite7
A: 

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.

JOM