Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.


  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • DownloadDownload
  • PrintPrint
Share this Page URL
Help

7. Advanced Topics > Time for action — using course for direction in your app

Time for action — using course for direction in your app

We modify the Hello Location - Location Updates example, to add course and speed values in the Hello Location app.

  1. Open the Hello_LocationViewController.h file, and add two outlets, one for the speed data and another for the course data.
    @property (retain, nonatomic) IBOutlet UITextField *courseText;
    @property (retain, nonatomic) IBOutlet UITextField *speedText;
    
  2. We just need the speed and course information, so we add two labels and two UITextFields in our XIB file as shown in the following screenshot. Also, we connect the same to the outlets created previously.
    Time for action — using course for direction in your app
  3. In our ViewDidLoad method, we change the location manager's accuracy to kCLLocationAccuracyBestForNavigation.
  4. Next, in the didUpdateToLocation and locationDetect, we fetch the values of speed and course from the CLLocation object.
    courseText.text = [[NSString alloc] initWithFormat:@"%f",newLocation.course];
    speedText.text = [[NSString alloc] initWithFormat:@"%f",newLocation.speed];
    

  

You are currently reading a PREVIEW of this book.

                                                                                        

Get instant access to over
$1 million worth of books and videos.

  

Start a Free Trial