目前有我的應用程序inteface一個按鈕,允許打開一個文件,這裏是我的開放代碼:可可/對象 - - 打開文件拖放到應用程序圖標時
在我app.h:
- (IBAction)selectFile:(id)sender;
在我app.m:
@synthesize window;
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
}
- (IBAction)selectFile:(id)sender {
NSOpenPanel *openPanel = [NSOpenPanel openPanel];
NSArray *fileTypes = [NSArray arrayWithObjects:@"xml",nil];
NSInteger result = [openPanel runModalForDirectory:NSHomeDirectory() file:nil types:fileTypes ];
if(result == NSOKButton){
NSString * input = [openPanel filename];
如何編輯我的代碼,以便與應用程序圖標拖動&滴口?
注意:我編輯了.plist文件並添加了一行「xml」,但它改變了任何內容,當我的文件被放在圖標上時發生錯誤。
注2:我鏈接的「文件 - >打開...」以選擇文件:至極參考我的代碼
注3:我的應用程序不是基於文檔的應用程序
感謝您的幫助!
Miskia
爲什麼不使用NSDocument?不夠靈活? – 2011-03-16 21:18:26