If the loss of precision that you have by converting the number one time is acceptable, then I would just quit converting back and forth every time that you display/save it, and only convert, if needed, when the value is entered by the user.
So in other words, just like in your user defaults, only ever have the value in memory represent km.
- (void)textFieldDidEndEditing:(UITextField *)textField {
intTotalKM = [textField.text intValue];
if ([unit isEqualToString:@"mile"]) {
intTotalKM = intTotalKM / 0.621371192;
}
}
Note that this conversion is only done once when the user enters a new value.
To display the value to the user, you would convert the value to miles if needed. When you save the value, you simply save intTotalKM without doing any conversion since it is always stored in KM.
Otherwise, you should store the value in such a way that you won't have this loss of precision. By storing the decimal portion of the number (using a double), by saving as a different unit (like meters - my personal favorite) or by storing the unit and using native values, all as suggested in other answers here.