我有一个将距离作为 NSString 返回的项目。我想检查该距离是否小于或等于或大于 10,000 英尺。我遇到了一个错误,上面写着“ARC不允许将'int'隐式转换为'NSString *'。” 有谁知道如何将 NSString 转换为 Integer?或者如何构造代码?谢谢!
- (IBAction)btnPress:(id)sender {
NSString *distanceInFeet = [[NSUserDefaults standardUserDefaults]
stringForKey:@"distanceInFeet"];
if ([distanceInFeet intValue] <= 10000)
{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Close" message:@"Distance is close" delegate:self cancelButtonTitle:@"Dismiss" otherButtonTitles:nil, nil];
[alert show];
return;
else
{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Far" message:@"Distance is far" delegate:self cancelButtonTitle:@"Dismiss" otherButtonTitles:nil, nil];
[alert show];
return;
}
}