I have saved all my files using something like this
NSString *fileName = [NSString stringWithFormat:@"%@.plist", myName];
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *appFile = [documentsDirectory stringByAppendingPathComponent:fileName];
[myDict writeToFile:appFile atom开发者_StackOverflowically:YES])
//where myDic is a dictionary containing the value of all parameters I would like to save.
All these files were saved with the .plist extension. The same directory contains several JPG and PNG files.
Now, how do I retrieve the list of all .plist files on that directory?
thanks for any help.
you can use the following call to get a list of all files in a given path and then iterate through the list filtering any files with .plist extension:
NSDirectoryEnumerator *dirEnum = [[NSFileManager defaultManager] enumeratorAtPath:docsDir];
NSString *file;
while (file = [dirEnum nextObject]) {
if ([[file pathExtension] isEqualToString: @"plist"]) {
// process the document
}
}
精彩评论