2015-08-15 142 views
0

這可能是一個相當奇怪的問題,我試圖找出高度的數據類型,我不確定我是否應該這樣稱呼它。但任何建議都會超級有用。所以的代碼,我需要幫助該位是在這裏:海拔高度的數據類型

var latitude:CLLocationDegrees = 0 
var longitude:CLLocationDegrees = 0 
var speed:CLLocationSpeed = 0 
var course:CLLocationDirection = 0 
var altitude:CLLocation 

正如你所看到的,var altitude:CLLocation沒有完全聲明,因爲我不知道它的數據類型。我應該寫什麼來完成這個聲明?只是爲了給你一些情況下,這裏是完整的代碼(我不認爲這是必要的讀取所有的,但這裏是):

// 
// ViewController.swift 
// Map Demo My Try 
// 
// Created by Jae Hyun Kim on 8/14/15. 
// Copyright © 2015 Jae Hyun Kim. All rights reserved. 
// 

import UIKit 
import MapKit 

class ViewController: UIViewController, MKMapViewDelegate, CLLocationManagerDelegate { 

    var locationManager = CLLocationManager() 

    var latitude:CLLocationDegrees = 0 
    var longitude:CLLocationDegrees = 0 
    var speed:CLLocationSpeed = 0 
    var course:CLLocationDirection = 0 
    var altitude:CLLocation 

    @IBOutlet weak var longitudeLabel: UILabel! 
    @IBOutlet weak var latitudeLabel: UILabel! 

    override func viewDidLoad() { 
     super.viewDidLoad() 

     locationManager.delegate = self 
     locationManager.desiredAccuracy = kCLLocationAccuracyBest 
     locationManager.requestWhenInUseAuthorization() 
     locationManager.startUpdatingLocation() 
    } 

    override func didReceiveMemoryWarning() { 
     super.didReceiveMemoryWarning() 
     // Dispose of any resources that can be recreated. 
    } 


    func locationManager(manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) { 
     print(locations) 
     let userLocations: CLLocation = locations[0] 
     latitude = userLocations.coordinate.latitude 
     longitude = userLocations.coordinate.longitude 
     let speed = userLocations.speed 
    } 




    @IBAction func getInformation(sender: AnyObject) { 
     longitudeLabel.text = String(latitude) 
     latitudeLabel.text = String(longitude) 

    } 
} 

任何幫助,將不勝感激!

回答

2

類型的高度的是CLLocationDistance(如在CLLocation Reference說明) CLLocationDistanceDouble一個typealias。