0

I'm trying to find the Swift equivalent of ~/.

So, I want to create an NSURL with the user path. I've looked at NSURLComponents, but I can't see anything there. The user var seems only to apply to existing URLs. I'm sure this is pretty basic, but haven't found anything.

benwiggy
  • 1,440
  • 17
  • 35

1 Answers1

3

To get the home directory in Swift you just need to use the following:

let homeDirectory = NSHomeDirectory()

This will print out:

/Users/FOLDER_NAMED_AFTER_USER
Rashwan L
  • 38,237
  • 7
  • 103
  • 107