0
我正在嘗試在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*
}
從[NSFileManager]開始(https://developer.apple.com/library/ios/documentation/Cocoa/Reference/Foundation/Classes/NSFileManager_Class/Reference/Reference.html)。你需要的一切都在那裏。 –