What does the /private prefix on an iOS file path indicate?

前端 未结 6 899
孤城傲影
孤城傲影 2020-12-14 15:34

I have a bug when my app runs on the iPhone but not when it runs on the simulator. I was using the length of the home directory path to extract the relative path of a file

6条回答
  •  鱼传尺愫
    2020-12-14 16:10

    1. In my case while using FileManager.default.fileExists to check whether the file already exists but i was using .absoluteString/"()". instead of .path for passing URL as String.
    2. When i printed the paths of the files in Documents Directory using

    let fileURLs = try fileManager.contentsOfDirectory(at:

    it printed as /private/var

    let DocumentDirURL = try! FileManager.default.url(for: .documentDirectory, in: .userDomainMask, appropriateFor: nil, create: true)

    it printed as /var

    1. This difference in path made me confused.
    2. As explained Above its just symlink. ie both the paths are same.

    :)

提交回复
热议问题