I've the following code in objC:
if ([delegate respondsToSelector:shouldCloseSelector]) {
// Create the invocation object
ms = [delegate methodSignatureForSelector:shouldCloseSelector];
inv = [NSInvocation invocationWithMethodSignature:ms];
// Set the target, selector, and parameters
[inv setTarget:delegate];
[inv setSelector:shouldCloseSelector];
[inv setArgument:&windowController atIndex:2];
[inv setArgument:&shouldClose atIndex:3];
[inv setArgument:&contextInfo atIndex:4];
// Invoke!
[inv invoke];
}
I've no idea how I can translate this into Swift (3). NSInvocation
is not available and the performSelector
versions take only objects and only two arguments.
Using closures (the most suggested solution) is not an option as this is in an override of NSDocument
's -(void)shouldCloseWindowController:(NSWindowController *)windowController delegate:(id)delegate shouldCloseSelector:(SEL)shouldCloseSelector contextInfo:(void *)contextInfo
, so I'm out of control here.
How can I still call that selector on the delegate?