无法调用非功能类型'AVAudioSession.RecordPermission'的值

时间:2018-11-16 18:07:19

标签: swift

我收到此错误:(从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插件,这是什么问题?

1 个答案:

答案 0 :(得分:1)

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