我试图在 Objective C 中遍历一个目录。我可以在 Java 中执行此操作,但如何在 Objective C 中执行此操作却让我难以理解。我正在使用 XCode5 并试图远离 C++/C。
我有一些,但到目前为止,我错过了一些东西。
- (IBAction)buttonPush:(id)sender {
NSLog(@"Button Pushed");
NSOpenPanel* panel = [NSOpenPanel openPanel];
[panel setCanChooseDirectories:YES];
// [panel setAllowsMultipleSelection:YES]; // not now
[panel setMessage:@"Select one or more, files or directories."];
[panel beginWithCompletionHandler:^(NSInteger result){
NSLog(@"OPEN Pushed");
if (result == NSFileHandlingPanelOKButton) {
NSArray* urls = [panel URLs];
[self parseArray:urls]; *// How do I use the URL?NSURL?
// Need to know if selected is File or Directory.
// If File, what is the file attributes
// If Directory, list the contents of the directory: procedure to recursively handle*
}