Opening Files - Cocoa

How can I open files from my application? For example, they type a directory in a text box called "inputBox", and they click the open button to open the file.

thanks

Kevin

+3
source share
4 answers

You can use the NSWorkspace class to open files.

It has several useful methods:

Opening files

openFile:  openFile:withApplication:  openFile:fromImage:at:inView:  openFile:withApplication:andDeactivate:  openTempFile:  openURL: 

Their descriptions are given in the docs at https://developer.apple.com/library/mac/documentation/Cocoa/Reference/ApplicationKit/Classes/NSWorkspace_Class/index.html

+10
source

, , , , , . Mac. , , Xcode.

- NSOpenPanel. , , , , .

+5

, "inputBox", open, .

NSOpenPanel ? , , : URL ( ), .

+3

, .

, ...

 NSString *logFilePath=seedFileDirectory=[[NSString alloc]initWithFormat:@"%@/LOCAL FILE NAME ",NSHomeDirectory()];

, logFilePath, , ...

 - (IBAction)viewFile:(id)sender {

[[NSWorkspace sharedWorkspace] openFile:logFilePath];

}

!!!

0

Source: https://habr.com/ru/post/1715748/


All Articles