所以这个问题困扰我太久了。我有 a UIAlertView
,textField
我需要textField
as a的值NSNumber
。但是我尝试的一切都会给我随机的数字串。任何帮助将不胜感激。
int i = [[alertView textFieldAtIndex:0].text intValue];
NSNumber *number = [NSNumber numberWithInt:[[alertView textFieldAtIndex:0].text integerValue]];
int number = [[dict objectForKey:@"integer"] intValue];
NSLog(@"text = %@", [alertView textFieldAtIndex:0].text);
NSString *alertText = [alertView textFieldAtIndex:0].text;
NSNumberFormatter * f = [[NSNumberFormatter alloc] init];
[f setNumberStyle:NSNumberFormatterNoStyle];
NSNumber * myNumber = [f numberFromString:[alertView textFieldAtIndex:0].text];
NSNumber *number = @([alertText intValue]);
NSString *string = @"54";
NSNumber *number = @([string intValue]);
NSLog(@"here we are: %i", number);