【发布时间】:2015-10-08 22:00:50
【问题描述】:
代码在 Swift 1.2 中运行良好,但是当我更改 Xcode 7 (Swift 2) 时,出现错误,该错误写在下面的 if 语句中。
let objFirstSound = AVPlayerItem(URL:NSURL(fileURLWithPath: NSBundle.mainBundle().pathForResource(self.objVowels?.main_sound, ofType: "mp3") ?? ""))
if objFirstSound != nil {
arrTemp.append(objFirstSound)
}
二元运算符“!=”不能应用于类型的操作数 'AVPlayerItem' 和 'NilLiteralConvertible'
那么,我如何检查AVPlayerItem实际上是Nil?
【问题讨论】:
标签: swift swift2 avfoundation xcode7 avplayeritem