에서 비동기 함수의 결과를 내 코드에 관한 질문이 기다립니다아이폰 OS
func isNotificationsEnabled()->Bool{
var isNotificationEnabled = false
center.getNotificationSettings() { (settings) in
switch settings.soundSetting{
case .enabled:
isNotificationEnabled = true
break
case .disabled:
isNotificationEnabled = false
break
case .notSupported:
isNotificationEnabled = false
break
}
}
return isNotificationEnabled
}
이 함수의 반환 결과 center.getNotificationSettings()
전에 결과를 반환합니다. center.getNotificationSettings()
의 결과를 기다리고이 기능을 동기화 할 수있는 방법이 있습니까?
가능한 복제본 [Swift 함수에서 비동기 호출에서 데이터 반환] (http://stackoverflow.com/questions/25203556/returning-data-from-async-call-in-swift- 기능) –
묻지 말고, 말해! 비동기 완료 핸들러를 사용하십시오. – vadian