vendredi 22 mai 2015

iOS Share Extension - How to access core data

I have a host application which fetches information from Core Data. Now i need a share extension and which going to show some information from host app's data.

I have already enabled app group and defined for both Host and Extension , i can access this path from my extension.

 NSURL *storeURL = [[NSFileManager defaultManager] containerURLForSecurityApplicationGroupIdentifier:@"com.application"];

It only have a /Library path when i get directory and files.

NSArray * files = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:url error:nil];
[files enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) {
    NSLog(@"fileName : %@",(NSString *)obj);
}];

My host app's sqlite file is under Documents directory. How can i make this sqlite file available under Shared Container ? Do i need to move whole database ? Any other solution.

Thanks

Aucun commentaire:

Enregistrer un commentaire