The iOS application library directory <uid> always changes

After reading the Apple documentation , I used URLsForDirectory to get the library destination in my application, and my goal is to download content from the hosted service and cache it in the Library folder so that the user cannot interact with the content through iTunes. NSArray *docPaths= [[NSFileManager defaultManager] URLsForDirectory:NSLibraryDirectory inDomains:NSUserDomainMask]; NSLog(@"%@",[docPaths description]); NSString *docPath=[(NSURL *)[docPaths objectAtIndex:0] path]; docPath = [docPath stringByAppendingPathComponent:@"audios"];

By executing and executing the code several times (various simulators and iOS 8.0 device), I realized that somehow the received content seems to be no longer available, so I registered the library path and after starting the application every time the destination is apparently has changed:

/ var / mobile / Containers / Data / Application / 83725F33-C7EA-4F89-B69F-0AECF26FA77A / Library / "

/ var / mobile / Containers / Data / Application / 4627FC86-C3A4-4A1A-9721-AF73D808433E / Library / "

/ var / mobile / Containers / data / applications / 709CCA84-936A-4596-933A-D6779758FF85 / Library /

Has anyone encountered a similar problem? If so, how was this fixed? And is there something I missed here?

+2
ios objective-c iphone nsfilemanager
source share
1 answer

I had the same problem. I think that the variable part changes only when the code is recompiled (i.e.No, if you just restart without making changes), therefore it should not affect the live application. But I decided, in the end, not to save the path - just use the same code (as you use above) when saving and retrieving data. This seems to work, even though the path actually changes between runs (so the simulator should copy files or rename the folder).

+4
source share

All Articles