Can an iPhone application write files?

So, I know that iOS apps work in the sandbox and that’s it, but I thought I remembered that Apple mentions how apps can write and read from a shared resource so that you can then handle these files on your computer, when you connect the iPhone (mount the drive). I think it was in the context of the iPad, but I'm not sure.

Does anyone know more about this? This is kind of a difficult thing to search.

+3
source share
3 answers

Each application has a Documents directory in which it can write files. To get a catalog of application documents that you can use:

NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];

", !" hello.txt - :

NSString *hello = @"Hello, World!";
NSString *myFile = [documentsDirectory stringByAppendingPathComponent:@"hello.txt"];
[hello writeToFile: myFile atomically:YES encoding:NSUTF8StringEncoding error:NULL];

UIFileSharingEnabled Info.plist - YES, iTunes, .

+11

/Documents. . UIFileSharingEnabled Info.plist YES, "" iTunes, , , , .

UIFileSharingEnabled (, , ).

+2
+1
source

Source: https://habr.com/ru/post/1762681/


All Articles