gpt4 book ai didi

objective-c - 为什么带有属性的 createDirectory AtPath 不起作用

转载 作者:行者123 更新时间:2023-12-03 17:13:56 25 4
gpt4 key购买 nike

在 OS X 桌面应用程序中

NSFileManager *manager = [NSFileManager defaultManager];

NSDictionary *dirMeta = [NSDictionary dictionaryWithObjectsAndKeys:@"jack", @"creator", nil];
NSLog(@"%@", [dirMeta objectForKey:@"creator"]);//output jack

[manager createDirectoryAtPath:@"/Users/loki/Desktop/fromCap" withIntermediateDirectories:YES attributes:dirMeta error:NULL];

NSDictionary *attri2 = [manager attributesOfItemAtPath:@"/User/loki/Desktop/fromCap" error:nil];
NSLog(@"value is %@", [attri2 objectForKey:@"creator"]);//output null

我是否错误地使用了createDirectoryAtPath?为什么 attri2 从目录中得不到任何数据?

最佳答案

attributes字典用于指定新目录/文件的文件系统属性:

attributes The file attributes for the new directory and any newly created intermediate directories. You can set the owner and group numbers, file permissions, and modification date. If you specify nil for this parameter or omit a particular value, one or more default values are used as described in the discussion. For a list of keys you can include in this dictionary, see “Constants” section lists the global constants used as keys in the attributes dictionary. Some of the keys, such as NSFileHFSCreatorCode and NSFileHFSTypeCode, do not apply to directories.

它们不用于附加任意元数据。您认为这些元数据将存储在哪里?

关于objective-c - 为什么带有属性的 createDirectory AtPath 不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12857065/

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