我正在尝试在Swift中使用Core Location的CLFloor功能获取数据,但是一直返回nil,而我还没有成功。我已经尝试了自己编写的代码和NSHipster提供的以下代码:
import CoreLocation
class LocationManagerDelegate: NSObject, CLLocationManagerDelegate {
func locationManager(manager: CLLocationManager!, didUpdateLocations locations: AnyObject[]!) {
let location: CLLocation? = locations[0] as? CLLocation
if let floor: CLFloor? = location?.floor {
println("Current Floor: \(floor?.level)")
}
}
}
let manager = CLLocationManager()
manager.delegate = LocationManagerDelegate()
manager.startUpdatingLocation()
有人知道如何在设备或模拟器上使其工作吗?我相信答案会惠及很多人。如果有人知道任何关于此或CLVisit的好资源,那也会很有帮助。