Я пытаюсь создать приложение, использующее GPS, а ниже - мой класс для контроллера GPS. Мой кортеж для широты и долготы дает предупреждение компилятора, если я попытаюсь объявить его как public
.«Объявление публичного доступа для внутреннего класса» - Swift
class CoreLocationController : NSObject, CLLocationManagerDelegate {
var locationManager:CLLocationManager = CLLocationManager()
public let ltuple: (latitude:Double, longitude:Double)?;
let location: CLLocation?
override init() {
super.init()
self.locationManager.delegate = self
self.locationManager.desiredAccuracy = kCLLocationAccuracyBest
self.locationManager.requestAlwaysAuthorization()
self.locationManager.startUpdatingLocation()
}
func locationManager(manager: CLLocationManager!, didChangeAuthorizationStatus status: CLAuthorizationStatus) {
println("didChangeAuthorizationStatus")
switch status {
case .NotDetermined:
println(".NotDetermined")
self.locationManager.requestAlwaysAuthorization() //Will use information provided in info.plist
break
case .Authorized:
println(".Authorized")
self.locationManager.startUpdatingLocation()
break
...
};
}
func locationManager(manager: CLLocationManager!, didUpdateLocations locations: [AnyObject]!) {
//Important things
let location = locations.last as CLLocation;
let ltuple = (location.coordinate.latitude, location.coordinate.longitude)
let geocoder = CLGeocoder()
//Printing
let str = "didUpdateLocations: "+String(format:"%f", location.coordinate.latitude)+String(format:"%f", location.coordinate.longitude);
println(str)
println(ltuple)
}
func locationManager(manager: CLLocationManager!, didFailWithError error: NSError!) {
println(error)
}
};
Когда я пытался избавиться от второго let
, это дает мне «Невозможно назначить ltuple
для self
». Есть идеи?