Swift:Int不能转换为'@lvalue inout _'

时间:2015-07-14 18:35:05

标签: ios swift avfoundation

我在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 _'我不明白这一点,也不知道如何修复它。感谢

1 个答案:

答案 0 :(得分:4)

上下文必须是var。您无法将let作为inout参数传递。