1

From the great post here I learned how to read/write files in Swift. I'm having a hard time changing the directory, however.

The line

let dir = FileManager.default.urls( for: .documentDirectory, in: .userDomainMask ).first

points to the user's Documents directory with .documentDirectory. Are there other constants that can be used in place of .documentDirectory that point to common directories such as the Desktop directory? I searched the API reference for .documentDirectory, tried various guesses like ".currentDirectory" (which didn't work), searched stackoverflow, etc. and am coming up empty.

Many thanks in advance!

Community
  • 1
  • 1
Dribbler
  • 4,343
  • 10
  • 33
  • 53
  • 1
    Your question isn't clear. What exactly are you trying to change? Do you want to change where the Documents directory is or are you asking about directories other than the Documents directory? – rmaddy Jan 02 '17 at 03:55
  • I was asking about directories other than the Documents directory. But I don't understand how this is specified in the default.urls construct. Is the process to have a handful of different kinds of directories specified in the for: or is it to get .documentDirectory to point somewhere else? The lack of clarity in my question derives from my lack of understanding of that process, mea culpa. – Dribbler Jan 02 '17 at 04:02
  • Why don't you update your question with details about what you are trying to achieve. Then someone can point you in the proper direction about which directory is best. Meanwhile, look at the docs for `FileManager.SearchPathDirectory` (but note that only a few are useful in iOS). – rmaddy Jan 02 '17 at 04:04
  • You just answered my question :D I'll update the question to be more specific. – Dribbler Jan 02 '17 at 04:11

1 Answers1

0

Credit where due: Rmaddy answered my question in the comments--posting the link to documentation if anyone comes across this and needs it. The reference for the constants for default.urls can be found here.

Thanks!

Community
  • 1
  • 1
Dribbler
  • 4,343
  • 10
  • 33
  • 53