我正在使用这段代码来获取文件夹 pathTo_Folder 中包含的文件。我得到的是这样的:“file://localhost/Users/ronny/DEV/0200-ObjC4/ModernTimes/DrawingFun/linen/Tech-2.jpg”,“file://localhost/Users/ronny/DEV /0200-ObjC4/ModernTimes/DrawingFun/linen/Tech-3.jpg", "文件://localhost/Users/ronny/DEV/0200-ObjC4/ModernTimes/DrawingFun/linen/Tech-4.jpg", "文件://localhost/Users/ronny/DEV/0200-ObjC4/ModernTimes/DrawingFun/linen/Terra-1.jpg", "file://localhost/Users/ronny/DEV/0200-ObjC4/ModernTimes/DrawingFun/linen /Terra-2.jpg", "file://localhost/Users/ronny/DEV/0200-ObjC4/ModernTimes/DrawingFun/linen/Terra-3.jpg", "file://localhost/Users/ronny/DEV /0200-ObjC4/ModernTimes/DrawingFun/linen/Terra-4.png", "文件:
我想知道是否有一种方法可以只获取文件名而不包含像“Tech-2.jpg”这样的文件夹
NSString *pathTo_Folder = @"/Users/ronny/DEV/0200-ObjC4/ModernTimes/DrawingFun/linen";
NSFileManager *fileManager = [NSFileManager defaultManager];
NSArray *theFiles = [fileManager contentsOfDirectoryAtURL:
[NSURL fileURLWithPath:pathTo_Folder]
includingPropertiesForKeys:[NSArray arrayWithObject:NSURLNameKey]
options:NSDirectoryEnumerationSkipsHiddenFiles
error:nil];
来自瑞士的问候,罗纳德霍夫曼