I'm trying to use QuickLook in OSX. There are several problems with my sample code:
1) It does not preview the image.
2) I get these errors:
2019-05-05 08:35:17.898276+0100 QuickLook[13561:1658693] [default] Unable to load Info.plist exceptions (eGPUOverrides) 2019-05-05 08:35:17.963612+0100 QuickLook[13561:1658651] [General] -[QLPreviewPanel setDelegate:] called while the panel has no controller - Fix this or this will raise soon. See comments in QLPreviewPanel.h for -acceptsPreviewPanelControl:/-beginPreviewPanelControl:/-endPreviewPanelControl:. 2019-05-05 08:35:17.963759+0100 QuickLook[13561:1658651] [General] -[QLPreviewPanel setDataSource:] called while the panel has no controller - Fix this or this will raise soon. See comments in QLPreviewPanel.h for -acceptsPreviewPanelControl:/-beginPreviewPanelControl:/-endPreviewPanelControl:. 2019-05-05 08:35:18.050123+0100 QuickLook[13561:1658651] [Layout] Unable to simultaneously satisfy constraints: ( "", "", " (active)>", "", "" )
Will attempt to recover by breaking constraint
Set the NSUserDefault NSConstraintBasedLayoutVisualizeMutuallyExclusiveConstraints to YES to have -[NSWindow visualizeConstraints:] automatically called when this happens. And/or, set a symbolic breakpoint on LAYOUT_CONSTRAINTS_NOT_SATISFIABLE to catch this in the debugger. 2019-05-05 08:35:18.050436+0100 QuickLook[13561:1658651] [Layout] Unable to simultaneously satisfy constraints: ( "", "", " (active)>", "", "" )
Will attempt to recover by breaking constraint
Set the NSUserDefault NSConstraintBasedLayoutVisualizeMutuallyExclusiveConstraints to YES to have -[NSWindow visualizeConstraints:] automatically called when this happens. And/or, set a symbolic breakpoint on LAYOUT_CONSTRAINTS_NOT_SATISFIABLE to catch this in the debugger.
Here is the code:
import Cocoa
import Quartz
class ViewController: NSViewController, QLPreviewPanelDataSource, QLPreviewPanelDelegate {
override func viewDidLoad()
{
if let sharedPanel = QLPreviewPanel.shared()
{
sharedPanel.delegate = self
sharedPanel.dataSource = self
sharedPanel.makeKeyAndOrderFront(self)
}
}
func numberOfPreviewItems(in panel: QLPreviewPanel!) -> Int {
return 1
}
func previewPanel(_ panel: QLPreviewPanel!, previewItemAt index: Int) -> QLPreviewItem! {
let url = URL(fileURLWithPath: "myimage.jpg")
return url as QLPreviewItem
}
}
Please could anyone tell me what am I doing wrong?