Home > Software design >  URL(filePath: strPath) vs URL(fileURLWithPath: strPath)
URL(filePath: strPath) vs URL(fileURLWithPath: strPath)

Time:01-23

let url = URL(filePath: pathString!)
let url2 = URL(fileURLWithPath: pathString!)

I tried both and they worked both.

What's the difference between the two ways creating such an URL-object?

CodePudding user response:

String file paths are outmoded. Use file URLs. And not file URLs derived from a string file path; construct or obtain the URL legitimately. So the real answer is: don't use either of those methods.

  • Related