Document directory path of Xcode Device Simulator

前端 未结 21 1733
旧巷少年郎
旧巷少年郎 2020-11-28 02:28

In iOS 7, the document directory of the iOS simulators can be found in:

/Users/Sabo/Library/Application Support/iPhone Simulator/

However,

21条回答
  •  我在风中等你
    2020-11-28 03:04

    I faced the same issue when I stored the full path using CoreData. When retrieving the full path, it return null because the document folder UUID is different every time the app restarts. Following is my resolution:

    1. Make sure storing only the relative path of the document / file in CoreData. E.g. store "Files/image.jpg" instead of "/Users/yourname/.../Applications/UUID/Document/Files/image.jpg".
    2. Use the following to retrieve the app document location:

      [[[NSFileManager defaultManager] URLsForDirectory:NSDocumentDirectory inDomains:NSUserDomainMask] lastObject];

    3. Concatenate both #2 and #1 to get the full path of the document / file you want to retrieve.
    You can refer to Apple Developer Note: https://developer.apple.com/library/ios/technotes/tn2406/_index.html

提交回复
热议问题