I'm building a simple altimeter app and I want to be able to calibrate the altitude depending on where I am located above sea level.
So at the moment I am at 300m but I want to be able calibrate that so it says 0m, and make my location "sea level".
How would I implement the calibration?
MainView.h
import
import
import
@interface MainView : UIView { IBOutlet UILabel *altitude;
CLLocationManager *locmanager;
}
- (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *) oldLocation ;
- (void)locationManager:(CLLocationManager *)manager didFailWithError:(NSError *) error;
@end
And the .m file
MainView.m
@implementation MainView
-(void)awakeFromNib {
locmanager = [[CLLocationManager alloc] init]; [locmanager setDelegate:self]; [locmanager setDesiredAccuracy:kCLLocationAccuracyBest];
[locmanager startUpdatingLocation];
}
(void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation {
altitude.text = [NSString stringWithFormat: @"%.2f m", newLocation.altitude]; }
(void)locationManager:(CLLocationManager *)manager didFailWithError:(NSError *)error { altitude.text = @"0.00 m"; }
(id)initWithFrame:(CGRect)frame { if (self = [super initWithFrame:frame]) { // Initialization code } return self; }
(void)drawRect:(CGRect)rect { // Drawing code }
(void)dealloc { [super dealloc]; }
@end