I'm overriding NSDocumentControllers reviewUnsavedDocuments(withAlertTitle:cancellable:delegate:didReviewAllSelector:contextInfo:)
in Swift. The documentation says that the didReviewAllSelector has this signature, note it has 3 arguments:
- (void)documentController:(NSDocumentController *)docController didReviewAll: (BOOL)didReviewAll contextInfo:(void *)contextInfo
So I need to invoke the selector
on delegate
with three arguments. The problem I'm facing is that I cant seem to find a neat way to do this in swift.
The closest match I can find is that NSObject has perform(aSelector:with:with:)
taking 2 parameters. Is there something like this with 3 arguments?
Examaple code
func reviewUnsavedDocuments(withAlertTitle title: String?, cancellable: Bool, delegate: Any?, didReviewAllSelector: Selector?, contextInfo: UnsafeMutableRawPointer?) {
if let object = delegate as? NSObject {
object.perform(didReviewAllSelector, with: self, with: true ... and
now I need to add contextInfo as a third paramenter here?
}
}
I have done this successfully in obj-c using NSInvocation. But thats not available from swift :(