我在UIViewController类
之外声明了上下文和关键变量// player item contexts
private let PlayerItemStatusContext = 0
// player item keys
private let PlayerItemStatusKey = "status"
...
if status == AVKeyValueStatus.Loaded {
self.playerItem = AVPlayerItem(asset: asset)
self.playerItem?.addObserver(self, forKeyPath: PlayerItemStatusKey, options: NSKeyValueObservingOptions.Initial, context: &PlayerItemStatusContext)
//self.player = AVPlayer(playerItem: self.playerItem!)
//self.previewView.layer = self.player
}
addobserver行不断抛出错误:'Int'不能转换为'@lvalue inout _'我不明白这一点,也不知道如何修复它。感谢
答案 0 :(得分:4)
上下文必须是var
。您无法将let
作为inout
参数传递。