从xCode使用Swift语言获得编译错误消息:“额外参数userinfo in call”。问题是如何使用定时器的userInfo数据到通知中心的参数“userInfo”。在调用中额外参数userinfo
func onSetAudioWithTrackIndex(CurrentTrackIndex:Int, urlAudio: String){
........
//try to pass currentTrackIndex data to timerfire
playTimeClock = NSTimer.scheduledTimerWithTimeInterval(0.4, target: self, selector: "onSetPlayProgressTime:", userInfo: CurrentTrackIndex, repeats: true)
}
//Timerfire
func onSetPlayProgressTime(timer: NSTimer){
var currentTime = mediaPlayer.currentPlaybackTime
var playDuration = mediaPlayer.duration
var trackIndexDict = ["trackIndex" : timer.userInfo]
................
if currentTime == playDuration{
NSNotificationCenter.defaultCenter().postNotificationName(MPMoviePlayerPlaybackDidFinishNotification, object: self, userInfo: trackIndexDict)
}
return
}
您可以检查标签是正确和完整的 - 例如,这是什么语言? –
第一次在这里提出问题。更新的说明和标签。语言很快 – lotosn
请*复制/粘贴*您的*真实代码*。像'MPMoivePlayerPlaybackDidFinishNotification'这样的输入或者'userInfo [“trackIndex”:timer.userInfo]中的一个冒号“会让你的问题不清楚。 –