0

사용자 위치를 얻는 제 기능을 수행하기 위해 권한 부여 메시지가 사용자에게 필요한 권한을 얻을 수있는 기회를 놓치지 않도록 경고를 받기 위해 사전 권한을 만들었습니다.스위프트 사전 허가 오버레이

let ok = UIAlertAction(title: "Allow", style: .default, handler: { (action) -> Void in self.showHUD("loading...")

오류가 스위프트 컴파일러는 당신에게 문 때문에 그 오류를주고있다

답변

0

"표현의 유형이 더 컨텍스트없이 모호"우리가 말하는 아빠 : 섹션에서

func getCurrentLocation() { 
// Init LocationManager 
locationManager = CLLocationManager() 
locationManager.delegate = self 
locationManager.desiredAccuracy = 
kCLLocationAccuracyThreeKilometers; 

let alert = UIAlertController(title: "Allow Loction Services?", 
message: "This allows the app to your loction", 
preferredStyle: .alert) 

let ok = UIAlertAction(title: "Allow", style: .default, handler: { 
(action) -> Void in 
self.showHUD("loading...") 

if locationManager.responds(to: 
#selector(CLLocationManager.requestWhenInUseAuthorization)) { 
locationManager.requestAlwaysAuthorization() 
}} 
self.hideHUD() 
) 
} 



let cancel = UIAlertAction(title: "Not Now", style: .destructive, 
handler: { (action) -> Void in }) 

alert.addAction(ok); alert.addAction(cancel) 
present(alert, animated: true, completion: nil) 

locationManager.startUpdatingLocation() 
} 

self.hideHUD()은 완료 핸들러 블록을 표시하는 중} 호 외부에 있습니다.

난 당신이 HUD 숨길 또 다른 후 을 오는 대신에 위의 라인에 두 중괄호, 단일 중괄호를 원하는 것으로 의심 :

....... 
     locationManager.requestAlwaysAuthorization() 
    } 
    self.hideHUD() 
} 
........