Iterating through all the subfolders of a folder in iphone - iphone

IS there any efficient way to iterate through all the subfolders I've created inside my iphone App's Documents folder ? (Of course, without knowing their names or how many there are...)
Thanks...
Guy.

See the documentation for -[NSFileManager enumeratorAtPath:]. It contains sample code that does what you want.

Related

Dart (Flutter) iterate assets folder file content [duplicate]

I want to know if there is a way (with or without pubspec.yaml asset list) to read a directory where images will be stored, and create an array with all the paths to each image, so I can go through the array (say, with a FOR ) and create a gallery of photos. This with the purpose of being able to change, remove or add images from the directory without worrying about the paths being coded in assets.
I've read that I can use AssetBundle or RootBundle for this but I cant find any example doing so. Any help on this, even pointing me in a different approach, would be greatly appreciated.
Thanks!
EDIT: This got marked as a duplicate, but the question referenced as a duplicate is different in the sense that I need to scan a directory automatically , So I dont need to know any of the names of the files on the directory, I just want a way to read the directory (who's name I can know) and retrieve an array populated with the assets inside the directory.
There is (or at least used to be - beware, it's an implementation detail) an asset called AssetManifest.json. You can load that asset first, and it contains details of the actual assets.

How can I exclude a file from iTunes file sharing?

iTunes file sharing works by exposing all the files in /Documents
But I would want to explicitly exclude certain files. Is this possible?
UPDATED:
Specifically, one of my ad network SDK is storing a mraid.js in Documents.
If you don't want a file shared, don't store it in the Documents folder. Use the Application Support folder for example.
Another option is that iTunes won't show any files or folders from the Documents folder that start with a dot. You could rename the files you don't want to share with a dot or put them in a subfolder whose name begins with a dot.
Try looking at This Question. Also, depending on what you are storing, you can try using the NSUserDefaults instead.
There is no way to exclude files from File Sharing.
The files you need to share should be put under Documents directory and the files which you don't want to share should be kept in other directories. It'll solve the issue.

Why copy a plist from the resources to document?

This is what is my understanding: the resources in the project folder are read only. So, almost all examples show copying a plist from the resources to the app's document folder. Why can we not simply find the app's document folder (after first run) and create the initial plist there (i.e. in the documents folder of the app so that subsequently we can modify the plist via code?
The answer is: Yes, you can create an initial plist there. But before you do this, consider using NSUserDefaults to save the settings.
Because there might already be data needed in a plist when the app is first installed; and that data has to come from somewhere. Why not from a plist?
I would also suggest using the Library folder rather than the Documents folder, just in case you do file sharing via iTunes at some stage. The Documents folder is available to the end user, whereas the Library folder is not.

How can I download an entire directory?

Is it possible in Objective-C to download an entire directory to the documents directory so I would end up with a subfolder in the documents directory with a name of my choosing? Then, is it possible to delete that directory and all its contents without looping through all the files? Many thanks in advance.
The short answer is 'Yes, its possible' given that the directory and files in question are not larger than the available space on the device. If you are talking about some text files or some images then I don't see a problem.
Not so sure about deleting all the contents without first getting a pointer to the files but that shouldn't take long in any case.
Were you looking for specific code examples as well?
There is a similar question, and answer [here].1
You cannot download entire folders over the internet, you would have to list the files and download them one by one.
You can use NSFileManager to create, read and remove files in your apps folder. You can delete a complete folder without having to loop through all the items in the folder.
(BOOL)removeItemAtPath:(NSString )path error:(NSError *)error;
Have a look at the NSFileManager documentation:
NSFileManager documentation
Keep in mind that whenever you go outside the "sandbox" of your app, your app will be rejected by apple. So keep those files within your app's bundle.

How to create a list of directory and import images to them

As you knew, a iphone app has 4 directories: Application folder, Document, Library, tmp.
When app is installed in the first time, I want to:
Create a list of directories in Document folder
Import a list of images to each that directories.
I searched and found the way to create directory in Document folder by code.
[[NSFileManager defaultManager] createDirectoryAtPath:newDirectoryPath attributes: nil];
But following that way, user must create folder and import images by themself after installing app. I want my app do that.
Anybody know how to do it, please help me.
Thanks in advance!
Tien
I found out a solution for my situation. I mean that I want to create a list directory when app run at the first time. But now, I don't need to do it, I just need to add images to my resources folder and find the way to use them in interface builder.
Thanks you all for your attention and sorry for any inconvenient.
Regards,
Tien