Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use NSApplicationDidFinishLaunchingNotification to create our codes #20

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 12 additions & 11 deletions AutoImporter/AutoImporter/LAFAutoImporter.m
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
static LAFAutoImporter *sharedPlugin;

@interface LAFAutoImporter()
@property (nonatomic, strong) NSBundle *bundle;
@end

@implementation LAFAutoImporter
Expand All @@ -40,25 +39,27 @@ + (void)pluginDidLoad:(NSBundle *)plugin
NSString *currentApplicationName = [[NSBundle mainBundle] infoDictionary][@"CFBundleName"];
if ([currentApplicationName isEqual:@"Xcode"]) {
dispatch_once(&onceToken, ^{
sharedPlugin = [[self alloc] initWithBundle:plugin];
sharedPlugin = [[self alloc] init];
});
}
}

- (id)initWithBundle:(NSBundle *)plugin
{
- (instancetype)init {
if (self = [super init]) {
// init inspector
[LAFIDENotificationHandler sharedHandler];

// reference to plugin's bundle, for resource acccess
self.bundle = plugin;

[self loadKeyboardHandler];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(applicationDidFinishLaunching:)
name:NSApplicationDidFinishLaunchingNotification
object:nil];
}
return self;
}

- (void)applicationDidFinishLaunching:(NSNotification*)noti{
// init inspector
[LAFIDENotificationHandler sharedHandler];
[self loadKeyboardHandler];
}

- (void)loadKeyboardHandler {
EventHotKeyRef lafHotKeyRef;
EventHotKeyID lafHotKeyID;
Expand Down