0
當我雙擊文件時,應用程序已經運行,我的應用程序可以打開它應該使用的文件類型。但是,當應用程序尚未運行,我雙擊文件,應用程序啓動,但它不會打開文件。爲什麼會這樣?當我雙擊它並且應用程序沒有運行時,我的應用程序沒有打開文件
應用程序委託實現方法:
-(void) application:(NSApplication *)sender openFiles:(NSArray *)filenames {
for (NSString *name in filenames) {
NSLog(@"Openning files");
[self.topController addFileAtPath:name];
}
}
-(BOOL) application:(NSApplication *)sender openFile:(NSString *)filename {
NSLog(@"Openning file_");
[self.topController addFileAtPath:filename];
return YES;
}
你能避免這個技巧,如果你在applicationDidFinishLaunching中執行應用程序初始化:但是在之前調用的applicationWillFinishLaunching: –
中,我會嘗試一下。謝謝 – Ibolit