For the long time I receive a strange error, but only when running on a device. In simulator everything is just fine. What I do is moving sample files from app bundle directory to Documents directory on a device. I have tried all those methods for NSFileManager:
- (BOOL)copyItemAtPath:(NSString *)srcPath toPath:(NSString *)dstPath error:(NSError **)error
- (BOOL)moveItemAtPath:(NSString *)srcPath toPath:(NSString *)dstPath error:(NSError **)error
- (BOOL)linkItemAtPath:(NSString *)srcPath toPath:(NSString *)dstPath error:(NSError **)error
And every one throws errors like following:
2015-08-15 23:14:15.152 app[1010:339938] Error: Error Domain=NSCocoaErrorDomain Code=513 "“file.txt” couldn’t be linked because you don’t have permission to access “Documents”." UserInfo={NSSourceFilePathErrorKey=/var/mobile/Containers/Bundle/Application/verylongid/fastdict.app/Dictionaries/file.txt, NSUserStringVariant=( Link ), NSDestinationFilePath=/var/mobile/Containers/Data/Application/verylongid/Documents/file.txt, NSFilePath=/var/mobile/Containers/Bundle/Application/verylongid/fastdict.app/Dictionaries/file.txt, NSUnderlyingError=0x13666d5a0 {Error Domain=NSPOSIXErrorDomain Code=1 "Operation not permitted"}} in -[AppDelegate fillDirectoryWithSamplesIfEmpty]
How can I solve this problem?
Update: The solution found here really works! Good luck!