1. Resource sharing between applications, the shared documents are stored in the Documents/Inbox path of the sandbox:
(lldb) po localPath
/var/mobile/Containers/Data/Application/151DF2B1-576C-42B5- 8F5D-051132FF2494/Documents/Inbox/?? Microsoft Word ?? (2)-1.docx
This file exists, but I want to calculate the document size using the following method
NSFileManager *fileManager = [NSFileManager defaultManager];
if ([fileManager fileExistsAtPath:localPath]) {
size = [[fileManager attributesOfItemAtPath:localPath error:nil] fileSize];
}
Always returns NO, the file does not exist. I would like to ask if there is a problem with this path. Can't I judge it this way?
If the path is changed to /var/mobile/Containers/Data/Application/151DF2B1-576C-42B5-8F5D-051132FF2494/Documents/Inbox, the file will be detected
Waiting online~~~
Maybe the description of the problem is not very clear. If you have time, you can read this http://blog.csdn.net/zhonggaorong/article/details/51832089. What I do is let the third party When the app clicks "Open with other applications", the console that pops up at the bottom can have its own app, and then it will jump to its own app and call back openUrl: that method
The string after
Application/ will change every time the application is run. You should not share this path, and one application cannot access the file directory of another application.
According to iOS App, let your application be displayed in the list of other applications. iOS can add your application to "Activities" and open PDF files in MyApp
The string in the path is assigned by the system every time the application is installed. As long as it is not uninstalled, this path will remain unchanged
2. I suspect that the problem is caused by the path name containing illegal characters
3. The DOCUMENT directory is not a sandbox, but is used for sharing, cloud backup, and iTunes client
iOS apps are all sandboxed and can only access the directory under your own app. The string 151DF2B1-576C-42B5-8F5D-051132FF2494 in your app will change. So it needs to be obtained through relative paths. The reference code is as follows: