简体   繁体   中英

IOS:How to set file id in NSFileManager?

I have a json with

{
                        "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

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

how to pass the folder id value when i creating directory?

I don't know of any id field associated with directories that can be set. 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.

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....

To make it transparent, create a class that takes a FolderID and translates to something that the file manager can work with.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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