开发者

write content of nshomedirectory in array

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];
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜