gpt4 book ai didi

ios - 获取 iOS 文件系统目录中存储对象的所有属性

转载 作者:塔克拉玛干 更新时间:2023-11-02 09:18:20 27 4
gpt4 key购买 nike

我知道这个方法:resourceValueForKeys 给定一个 NSURL 和一组键会为你获取文件的属性...但我需要的是列举的东西遍历给定 NSURL 目录中的所有文件并提供属性。

我尝试使用 NSFileSystem 类中的枚举器来执行此操作,但无法使其正常工作,有人知道正确的方法吗?...我没有使用 Core Data。

   NSDictionary *values = [fileDirectory resourceValuesForKeys:@[NSURLAttributeModificationDateKey] error:nil];
NSLog(@"object: %@", values);

最佳答案

给你:

NSString *path = [NSHomeDirectory() stringByAppendingFormat:@"/Documents/your file path"];
NSLog(@"Your path: %@",path);
NSFileManager *fileManager = [NSFileManager defaultManager];
NSError *error;
NSDictionary *attributesOfYourItem = [fileManager attributesOfItemAtPath:path error:&error];
if(error)
NSLog(@"Error: %@",error);
else
NSLog(@"Attribute dictionary: %@",attributesOfYourItem);

关于ios - 获取 iOS 文件系统目录中存储对象的所有属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15314977/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com