dispatch_async e inesperado valor de retorno no nulo en la función nula en Swift
Tengo una función en miappDelegate
que devuelve la ubicación actual del usuario.
Ahora quiero llamarlo asincrónicamente en otro lugar y lo hice:
func handleLocation() -> CLLocation {
let priority = DISPATCH_QUEUE_PRIORITY_DEFAULT
dispatch_async(dispatch_get_global_queue(priority, 0)) {
let appDelegate = UIApplication.sharedApplication().delegate as! AppDelegate
appDelegate.startGPS()
while (!appDelegate.isLocationFixed()) {
sleep(1)
}
dispatch_async(dispatch_get_main_queue()) {
return appDelegate.getLocation()
}
}
}
pero ahora esta lineareturn appDelegate.getLocation()
me trae el error:
valor de retorno no vacío inesperado en la función vacía
No sé mucho sobre hilos enSwift
sin embargo, ¿podría ayudarme a solucionar este problema?