0

I have application that use QLPreviewController to show document from MS. Office. I use this controller to multiple files. I need to log which files that already viewed. But I can't find event that triggered when PreviewItem changed.

I try to trigger event when GetPreviewItem called, But this method just called 1 time each preview item. So I can't use this.

Anyone can help me to find how to detect QLPreviewItem changed?

mas_bejo
  • 597
  • 2
  • 6
  • 22

1 Answers1

0

You can do this with Key-Value Observing. Subclass the QLPreviewController and add something like this:

var observation: NSKeyValueObservation?

override func viewDidLoad() {
    super.viewDidLoad()

    observation = observe(\.currentPreviewItemIndex, options: [.new] ) { _, change in
        // You get the new index value in change.newValue
    }
}