【发布时间】:2020-01-10 16:01:15
【问题描述】:
我正在更新旧的媒体播放器项目 (Swift 3) 并出现奇怪的错误:
由于未捕获的异常而终止应用程序 'NSInternalInconsistencyException',原因:'不支持的操作方法 签名。必须返回 MPRemoteCommandHandlerStatus 或采取 完成处理程序作为第二个参数。
我在此代码上收到此错误:
UIApplication.shared.beginReceivingRemoteControlEvents()
let commandCenter = MPRemoteCommandCenter.shared()
commandCenter.previousTrackCommand.addTarget(self, action: #selector(handlePrevTrack))
@objc func handlePrevTrack(){
if playListEpisodes.count == 0 {
return
}
let currentEpisodeIndex = playListEpisodes.firstIndex { (ep) -> Bool in
return self.episode.title == ep.title && self.episode.author == ep.author
}
guard let index = currentEpisodeIndex else { return}
let nextEpisode:Episode
if index == 0 {
nextEpisode = playListEpisodes[playListEpisodes.count - 1]
}else {
nextEpisode = playListEpisodes[index - 1]
}
self.episode = nextEpisode
}
Swift 5.1 发生了什么变化?
【问题讨论】:
标签: ios swift media-player avkit