In iOS to get the delegate I use following开发者_如何学Python code:
AppDelegate *appDelegate = (AppDelegate *)[UIApplication sharedApplication] delegate];
How to get the delegate in Cocoa Mac programming?
AppDelegate *appDelegate = (AppDelegate *)[NSApp delegate];
see the docs for NSApplication for more info.
In Swift 5
let delegate = (NSApplication.shared.delegate) as! AppDelegate
精彩评论