objective-c - 获取从目录加载的 NSString 中的文件名

标签 objective-c ios

我已经使用以下方法从本地目录加载图像文件:

fotosJugadores = [[NSFileManager defaultManager] contentsOfDirectoryAtPath: @"/Users/exular/Developer/GBC/exular/GBC/Caras/" error: &error];

如何将每个文件名加载到 NSString 中?

最佳答案

从该方法返回的 NSArray 包含 NSString 对象,其中每个对象都是一个文件/目录/符号:

例如打印文件名:

fotosJugadores = [[NSFileManager defaultManager] contentsOfDirectoryAtPath: @"/Users/exular/Developer/GBC/exular/GBC/Caras/" error: &error];

for (NSString *file in fotosJugadores) {
    NSLog(@"File = %@", file);
}

关于objective-c - 获取从目录加载的 NSString 中的文件名,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10598609/

相关文章:

objective-c - 将 ivar 放在类扩展中有什么问题?

ios - 在 Objective-C 中,标识符后跟冒号是什么意思?

IOS Twitter 使用 PFLogInViewController 解析登录

iOS - wait_fences MFMessageComposeViewController

ios - 如何在 iPhone 的 xamarin 中捕获带有弹出窗口的屏幕截图?

ios - 将 NSTimeInterval 设置为分钟 :Seconds:milliseconds

iphone - 无 block 地遍历 NSMutableIndexSet

iphone - iOS:如何将 NSData 的长度添加为其两个字节的 header ?

ios - SpriteKit 标签节点未出现

objective-c - 如何在应用程序级别更改 iPhone 设置中的 UI