开发者

How to dump NSHomeDirectory file listing to NSLog

开发者 https://www.devze.com 2023-01-21 01:57 出处:网络
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:

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

精彩评论

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

关注公众号