快速观察多个NSKeyObservingKeyValueoptions

时间:2016-04-01 14:32:10

标签: swift key-value-observing

如何在swift中观察多个NSKeyObservingKeyValueoptions

 self.avplayerItem.addObserver(self, forKeyPath: "status", options:[.Initial | .New], context: nil)

我收到类似

的错误

错误

否' |'候选人产生预期的上下文结果类型' NSKeyValueObservingOptions'

1 个答案:

答案 0 :(得分:6)

更改

 self.avplayerItem.addObserver(self, forKeyPath: "status", options:[.Initial | .New], context: nil)

为:

 self.avplayerItem.addObserver(self, forKeyPath: "status", options:[.Initial, .New], context: nil)