Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
Let’s build a small application to detect the iPhone’s current location and the total distance traveled while the program has been running. You can see what our final application will look like in Figure 18–3.
Figure 18–3. The WhereAmI application in action. This screenshot was taken in the simulator. Notice that the vertical accuracy is a negative number, which tells us it couldn’t determine the altitude.
In Xcode, create a new project using the SingleView Application template, call the project WhereAmI, and set Device Family to iPhone. Select BIDViewController.h, and make the following changes:
#import <UIKit/UIKit.h>
#import <CoreLocation/CoreLocation.h>
@interface BIDViewController :
UIViewController <CLLocationManagerDelegate>
@property (strong, nonatomic) CLLocationManager *locationManager;
@property (strong, nonatomic) CLLocation *startingPoint;
@property (strong, nonatomic) IBOutlet UILabel *latitudeLabel;
@property (strong, nonatomic) IBOutlet UILabel *longitudeLabel;
@property (strong, nonatomic) IBOutlet UILabel *horizontalAccuracyLabel;
@property (strong, nonatomic) IBOutlet UILabel *altitudeLabel;
@property (strong, nonatomic) IBOutlet UILabel *verticalAccuracyLabel;
@property (strong, nonatomic) IBOutlet UILabel *distanceTraveledLabel;
@end