I have a project that returns a distance as an NSString. I want to check that distance to see if it is less or equal to, or more than 10,000 feet. I am running into an error that says “Implicit conversion of ‘int’ to ‘NSString *’ is disallowed with ARC.” Does anyone know how to convert the NSString into an Integer? or how to construct the code? Thank you!
- (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;
}
}
Why don’t you simply try this one?
OR
EDIT:
As per your edit of code, and correct error shown…