Macos Swift Quicklook Warning: Setdelegate and Setdatasource Called While The Panel Has No Controller

QLPreviewPanel in tableview with issue: has no controller

I found the solution here: QuickLook consumer as a delegate from an NSViewController. In my case i need these 3 lines of code in the panel controller (NSWindowController) where i have the instance of my table view controller.

- (void)awakeFromNib { 
NSResponder * aNextResponder = [self nextResponder];
[self setNextResponder:_tableController];
[_tableController setNextResponder:aNextResponder];
}

QuickLook consumer as a delegate from an NSViewController

Why would you expect it to send you delegate messages if you aren't (yet) its delegate? If you want it to send you delegate messages, then you need to set yourself as its delegate.

I tried calling a setDelegate, but get warned about impending doom if I continue down that route...

[QL] QLError(): -[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:.

“No controller”, it says. So, you need it to have a controller.

The comments on that header, particularly on acceptsPreviewPanelControl: and the QLPreviewPanel instance method updateController, suggest that the panel's controller, when it has one, is an object that is in the responder chain. Therefore, if your controller is not becoming the panel's controller, it's because your controller isn't in the responder chain.

So, fix that, and then it'll work.

I would imagine that your view controller should be in the responder chain whenever its view or any subview thereof is in the responder chain, but maybe this isn't the case. The documentation doesn't say. If all else fails, set yourself as some view's next responder explicitly (and its previous next responder as your next responder), then send the preview panel an updateController message.



Related Topics



Leave a reply



Submit