Clicky

iOS Dev Nugget 172 Print App Document Path

.

Need to run a code review on your codebase? Hire me

While running your app in the simulator, it's often useful to be able to open your app document directory to inspect data or drop in your own test data. Just drop this into -application:didFinishLaunchingWithOptions: and print it out:

NSString* docPath = [[NSFileManager defaultManager] URLsForDirectory:NSDocumentDirectory inDomains:NSUserDomainMask][0].path;

Or in Swift:

let docPath = NSFileManager.defaultManager().URLsForDirectory(NSSearchPathDirectory.DocumentDirectory, inDomains: NSSearchPathDomainMask.UserDomainMask).last?.path


Your feedback is valuable: Do you want more nuggets like this?   Yes   or   No

.

.

Like this and want such iOS dev nuggets to be emailed to you, weekly?

Sign Me Up! or follow @iosdevnuggets on Twitter

.

View archives of past issues