开发者

How to dump NSHomeDirectory file listing to NSLog

Is there a quick way to spit out a directory listing for a specific folder in NSHomeDirectory? I'm playing with an开发者_如何学Go example in ASIHTTPRequest that downloads an image via:

[request setDownloadDestinationPath:[[NSHomeDirectory() stringByAppendingPathComponent:@"Documents"] stringByAppendingPathComponent:@"totallyhotmilf.jpg"]];

I'd like to list the files in the Documents folder to see whats actually getting downloaded for debugging purposes. Thanks for the help.


Found an answer to my question thanks to this page. This will give you a nice file listing:

// Create file manager
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]);
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜