I am new in iPhone programming.
I would like to get the content of the NSHomeDirectory to an array.
I have found this code
NSError *error;
NSFileManager *fileMgr = [NSFileManager defaultManager];
// Point to Document directory
NSString *documentsDirectory = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents"];
// Write out the contents of home directory to console
NSLog(@"Documents directory: %@", [fileMgr contentsOfDirectoryAtPath:documentsDirectory error:&error]开发者_JAVA技巧);
cell.textLabel.text = [NSString stringWithFormat:@"%@", [fileMgr contentsOfDirectoryAtPath:documentsDirectory error:&error]];
Could someone give me a way to put the files in an nsmutablearray?!?
please help me
Have you tried just constructing an NSMutableArray with the returned array?
NSMutableArray *files = [NSMutableArray arrayWithArray:[fileMgr contentsOfDirectoryAtPath:documentsDirectory error:&error]];
Or use mutableCopy
on the returned array?
NSMutableArray *files = [[fileMgr contentsOfDirectoryAtPath:documentsDirectory error:&error] mutableCopy];
精彩评论