所以我要重新开始编程,但我遇到了一个问题。当我在其中存储值时,我的函数没有返回值。你们能看看并指出我为什么会这样吗?
func getLocation() -> NSString {
manager = OneShotLocationManager()
var tempLocation: NSString = "" // created an empty string for the var
manager!.fetchWithCompletion {location, error in
if let locatie = location {
tempLocation = String(locatie.coordinate.latitude) + "," + String(locatie.coordinate.longitude)
print(tempLocation) // It stores a value here but will not show it on the return
} else if let err = error {
tempLocation = err.localizedDescription
}
self.manager = nil
}
return tempLocation // It's not returning anything here..
}