我收到此错误:(从4.0切换到Swift 4.2时)
错误:无法调用非函数类型的值 “ AVAudioSession.RecordPermission” 切换AVAudioSession.sharedInstance()。recordPermission(){ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^ ~~
根据link
,以下代码应该没有问题switch AVAudioSession.sharedInstance().recordPermission() {
case AVAudioSession.RecordPermission.granted:
NSLog("granted")
hasPermissions = true
break
case AVAudioSession.RecordPermission.denied:
NSLog("denied")
hasPermissions = false
break
case AVAudioSession.RecordPermission.undetermined:
NSLog("undetermined")
AVAudioSession.sharedInstance().requestRecordPermission() { [unowned self] allowed in
DispatchQueue.main.async {
if allowed {
self.hasPermissions = true
} else {
self.hasPermissions = false
}
}
}
break
default:
break
}
我是新手,正在尝试重构flutter插件,这是什么问题?
答案 0 :(得分:1)
recordPermission
是属性,而不是函数。删除()
。