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

Chapter 18: Where Am I? Finding Your Way... > Wherever You Go, There You Are - Pg. 644

644 CHAPTER 18: Where Am I? Finding Your Way with Core Location newLocation.altitude]; altitudeLabel.text = altitudeString; NSString *verticalAccuracyString = [NSString stringWithFormat:@"%gm", newLocation.verticalAccuracy]; verticalAccuracyLabel.text = verticalAccuracyString; NOTE: Both the longitude and latitude are displayed in formatting strings containing the cryptic- looking \u00B0. This represents the Unicode representation of the degree symbol (°). It's never a good idea to put anything other than ASCII characters directly in a source code file, but including the hex value in a string is just fine, and that's what we've done here. Determining Distance Traveled Finally, we determine the distance between the current location and the location stored in startingPoint and display the distance. While this application runs, if the user moves far enough for the location manager to detect the change, the Distance Traveled: field will be continually updated with the distance away from where the user was when the application was started. CLLocationDistance distance = [newLocation distanceFromLocation:startingPoint]; NSString *distanceString = [NSString stringWithFormat:@"%gm", distance]; distanceTraveledLabel.text = distanceString;