-
-
Notifications
You must be signed in to change notification settings - Fork 6
/
MACHAppDelegate.m
42 lines (34 loc) · 961 Bytes
/
MACHAppDelegate.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#import <Foundation/Foundation.h>
#if TARGET_OS_OSX
#import <AppKit/AppKit.h>
#else
#import <UIKit/UIKit.h>
#endif
@interface MACHAppDelegate : NSObject
@end
#if TARGET_OS_OSX
@interface MACHAppDelegate () <NSApplicationDelegate>
#else
@interface MACHAppDelegate () <UIApplicationDelegate>
#endif
@end
@implementation MACHAppDelegate {
dispatch_block_t _runBlock;
}
- (void)setRunBlock:(dispatch_block_t)runBlock __attribute__((objc_direct)) {
_runBlock = runBlock;
}
#if TARGET_OS_OSX
- (void)applicationDidFinishLaunching:(NSNotification *)notification {
if (self->_runBlock) self->_runBlock();
}
#else
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary<UIApplicationLaunchOptionsKey, id> *)launchOptions {
if (self->_runBlock) self->_runBlock();
return YES;
}
#endif
- (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)sender {
return NSTerminateCancel;
}
@end