ludluck ludluck - 1 year ago 139
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.

Answer Source

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.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download