gpt4 book ai didi

swift - 无法调用非函数类型的值 'AVAudioSession.RecordPermission'

转载 作者:行者123 更新时间:2023-11-28 14:03:04 24 4
gpt4 key购买 nike

我收到这个错误:(从 4.0 切换到 swift 4.2 时)

error: cannot call value of non-function type 'AVAudioSession.RecordPermission' switch 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
}

我是 swift 的新手,正在尝试重构一个 flutter 插件,这里有什么问题?

最佳答案

recordPermission 是一个属性,而不是一个函数。删除 ()

关于swift - 无法调用非函数类型的值 'AVAudioSession.RecordPermission',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53343218/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com