I'm working on an iOS app that requires the user to enter numbers into a UITextField using the keyboard type UIKeyboardTypeDecimalPad. However I just realized that there is no support for entering negative numbers, which is a requirement of the application.
Any ideas or thoughts on how I can accomplish this?
may this code will help you:
if you want a negative number just use "-"
NSString *fieldString = [NSString stringWithFormat:@"%@",Textfield.text];
NSLog(@"%@",fString);
int fieldValue;
value = [fString intValue];
NSLog(@"%d",fieldValue);
this will work for decimal numbers
double fieldValue;
value = [fString doubleValue];
NSLog(@"%f",fieldValue);