简体   繁体   English

iOS:如何在NSFileManager中设置文件ID?

[英]IOS:How to set file id in NSFileManager?

I have a json with 我有一个json

{
                        "FolderID": "17",
                        "FolderName": "Outdoor Look",
                        "MarkForDeletion": false,
                        "NewUpdateFolderID": null,
                        "ParentFolderID": "0"
                        },
                        {
                        "FolderID": "20",
                        "FolderName": "Sub 1",
                        "MarkForDeletion": false,
                        "NewUpdateFolderID": null,
                        "ParentFolderID": "17"
                        },
                        {
                        "FolderID": "22",
                        "FolderName": "Sub 2",
                        "MarkForDeletion": false,
                        "NewUpdateFolderID": null,
                        "ParentFolderID": "17"
                        },

when i creating files i want to set folder id to each directory currently I was creating file like this 当我创建文件时,我想将文件夹ID设置为当前的每个目录,而我正在创建这样的文件

[fileManager createDirectoryAtPath:[[self applicationDocumentsDirectory]stringByAppendingPathComponent:FolderName] withIntermediateDirectories:YES attributes:nil error:&error];

how to pass the folder id value when i creating directory? 创建目录时如何传递文件夹ID值?

I don't know of any id field associated with directories that can be set. 我不知道与可以设置的目录相关联的任何ID字段。 If you want to use your id numbers, you should create your directory and then save its path or URL in your own dictionary with the FolderID as the key. 如果要使用ID号,则应创建目录,然后使用FolderID作为键将其路径或URL保存在您自己的字典中。

You can then store your dictionary in the user defaults and use the id to look up a matching path/URL which can be used for delete/rename.... 然后,您可以将词典存储在用户默认设置中,并使用ID查找可用于删除/重命名的匹配路径/ URL...。

To make it transparent, create a class that takes a FolderID and translates to something that the file manager can work with. 为了使其透明,请创建一个接受FolderID并转换为文件管理器可以使用的东西的类。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM