從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]中的一個冒號「會讓你的問題不清楚。 –