0
我第一次尝试构建watchOS应用程序开始有点粗糙。Watchkit扩展时的错误
当我在文件检查器的目标成员资格框中选择了watchkit扩展后,我的CLLocationManager委托类立即弹出了几个错误,我不知道为什么会出现这种情况,不知道如何跟踪这些答案问题。
因为它适用于手表,所以允许在iOS和watchOS的可共享代码中集成什么特殊限制?
不确定为什么特别是活动类型不可用。
import Foundation
import CoreLocation
import MapKit
import UIKit
class TrackLocationManagerDelegate: NSObject, CLLocationManagerDelegate {
lazy var locationManager: CLLocationManager = {
var locationManager = CLLocationManager()
locationManager.delegate = LocationManagerDelegate.sharedInstance
locationManager.desiredAccuracy = kCLLocationAccuracyBest
// ERROR - activityType unavailable
locationManager.activityType = CLActivityType.fitness
locationManager.distanceFilter = 10.0
return locationManager
}()
// ERROR - Use of undeclared type MKPolyline
fileprivate lazy var polyline = MKPolyline()
// ERROR - Use of Undeclared type UIViewController
func startUpdatingLocationIfAuthorized(inViewController vc: UIViewController) {
guard CLLocationManager.authorizationStatus() == .authorizedWhenInUse else {
TrackLocationManagerDelegate.sharedInstance.locationManager.requestWhenInUseAuthorization()
return
}
TrackLocationManagerDelegate.sharedInstance.locationManager.startUpdatingLocation()
}
}
谢谢,通过文档,它回答了我所有的问题! – lifewithelliott