Reputation: 121
In iOS to get the delegate I use following code:
AppDelegate *appDelegate = (AppDelegate *)[UIApplication sharedApplication] delegate];
How to get the delegate in Cocoa Mac programming?
Upvotes: 12
Views: 6873
Reputation: 304
In Swift 5
let delegate = (NSApplication.shared.delegate) as! AppDelegate
Upvotes: 2
Reputation: 19040
AppDelegate *appDelegate = (AppDelegate *)[NSApp delegate];
see the docs for NSApplication for more info.
Upvotes: 29