in iPhone application development, if you want to restrict users from entering unnecessary characters in text field then you can use the facility provide by NSCharcterSet. Below is the code snippets that allow user to enter only numeric characters into text-field.No other characters apart from numeric values will be inserted in text field.
- (BOOL)textField:(UITextField *)textField
(NSRange)range replacementString:(NSString *)string
static NSCharacterSet *charSet3 = nil;
charSet3 = [[NSCharacterSet
NSRange location = [string rangeOfCharacterFromSet:charSet3];
return (location.location == NSNotFound);