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?
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?
AppDelegate *appDelegate = (AppDelegate *)[NSApp delegate];
see the docs for NSApplication for more info.
In Swift 5
let delegate = (NSApplication.shared.delegate) as! AppDelegate
© 2022 - 2024 — McMap. All rights reserved.
NSApp
is really just the same thing as[NSApplication sharedApplication]
– Chipman