ludluck ludluck - 6 months ago 36
Swift Question

How do you use the function createFile?

I found this declaration in Apple's API reference but I'm not sure how to use it.

func createFile(atPath path: String, contents data: Data?, attributes attr: [String : Any]? = nil) -> Bool

When I start typing
, there is no auto-complete that resembles this declaration either.

My path is a directory on my computer (not including the file's name), and the data is a string.


It works fine on my machine. You probably just aren't using a FileManager object:

enter image description here


My path is a directory on my computer

Then you won't be able to write to it. How can an iPhone app see your computer? That makes no sense.