Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

kaydell.leavitt

macrumors regular
Original poster
Apr 19, 2010
100
0
I have several UITextFields in which the user can enter numbers representing money. I want to enable the user to only type in the digits zero through nine and the decimal point (a comma or a period).

How can I filter-out the characters that aren't allowed to be part of a currency string?

-- Kaydell :confused:
 
Documentation

Have you looked at the documentation? If so what? You need to learn to find the answers for yourself.

Here is the documentation that I'm looking at:

UITextFieldDelegate Protocol Reference
http://developer.apple.com/iphone/l.../UITextFieldDelegate/UITextFieldDelegate.html

UITextField Class Reference
http://developer.apple.com/iphone/l.../UITextField_Class/Reference/UITextField.html

I'm thinking that I can make my own custom class that adheres to the UITextFieldDelegate protocol and set it for my text fields and then implement the method:

Code:
- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string

Am I on the right track?
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.