I have a method that attempts to update my authorized status.
Using PromiseKit 6, Swift 4.2, I can't seem to get my Promise<[CLPlacemark]> to just be a CLPlacemark.
This causes a chain of errors of
Value of type 'Promise<[CLPlacemark]>' has no member 'foo'
Here's a look at my code:
func updateAuthStatus(status: CLAuthorizationStatus) {
if status == .authorizedWhenInUse {
titleLabel.isHidden = true
bigIconView.isHidden = true
descriptionLabel.isHidden = true
grantBtn.isHidden = true
titleLabel1.isHidden = false
loaderView.isHidden = false
loaderView.resumeSpinning()
CLLocationManager.requestLocation().compactMapValues { location in
return self.coder.reverseGeocode(location: location)
}.compactMapValues { placemark -> Void in
if placemark.ISOcountryCode == "CA" {
self.seal.fulfill(())
} else if placemark.ISOcountryCode == "US" {
if self.allowedStates.contains(placemark.administrativeArea ?? "") {
self.seal.fulfill(())
} else {
self.seal.reject(LocationError.InvalidState(placemark.administrativeArea ?? ""))
}
} else {
self.seal.reject(LocationError.InvalidCountry(placemark.ISOcountryCode ?? ""))
}
}
}
else if status == .denied || status == .restricted {
if denied == false {
self.seal.reject(LocationError.Unknown)
}
denied = true
}
}