IOS8: sharing shared files between applications

Two iOS: AppA and AppB

Both applications were created by me, and I would like to share one file between both applications.

i.e. AppA starts on device A, and the user saves the data in fileA. Later, the user launches AppB on the same (deviceA), and also saves the data in fileA. Both applications save data in one file.

I know that I can use NSUserDefaultsand share Keychainbetween applications, but this is not what I am looking for.

I read about document extension providers and application groups, but am I confused if I can use them for this scenario? Or is there any other way to do this?

+4
source share
2 answers

, :

NSFileManager *fm = [NSFileManager defaultManager];
NSString *appGroupName = @"Z123456789.com.example.app-group"; /* For example */

NSURL *groupContainerURL = [fm containerURLForSecurityApplicationGroupIdentifier:appGroupName];
NSError* theError = nil;
if (![fm createDirectoryAtURL: groupContainerURL withIntermediateDirectories:YES attributes:nil error:&theError]) {
    // Handle the error.
}
+1

.

, :)

0

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


All Articles