Xcode 11, Swift 5.1
I'm getting a couple warnings every time I open a file and view it with QuickLook (QL). It seems to be working fine, but I'm wondering if I can get rid of the warnings.
The warnings say:
-[QLPreviewPanel setDelegate:] called while the panel has no controller - Fix this or this will raise soon.
-[QLPreviewPanel setDataSource:] called while the panel has no controller - Fix this or this will raise soon.
I set up and use QL on an NSTableCellView
like this:
import Quartz
class AttachmentCell: NSTableCellView, QLPreviewPanelDataSource, QLPreviewPanelDelegate{
var quickLookItem:URL!
@IBAction func clickPreview(_ sender: Any) {
guard let panel = QLPreviewPanel.shared() else{ return }
panel.delegate = self
panel.dataSource = self
panel.makeKeyAndOrderFront(self)
}
func numberOfPreviewItems(in panel: QLPreviewPanel!) -> Int {
return 1
}
func previewPanel(_ panel: QLPreviewPanel!, previewItemAt index: Int) -> QLPreviewItem! {
quickLookItem = URL(fileURLWithPath: "...").appendingPathExtension(...)
return quickLookItem as QLPreviewItem
}
}
The clickPreview
method is on an NSButton
I have in my table cell. The closest thing I could find was this, but I don't see how the responder chain is involved: QLPreviewPanel in tableview with issue: "has no controller"
I also tried setting up my delegate methods on my NSViewController
instead, but the same warning shows up.
Any ideas how to solve this? Or can I safely ignore it?