IOS File Creation Accessible To All Apps

159 views Asked by At

I need to create an HTML and PDF File within my app and save it in Documents Directory. This File contains the user transaction details for a particular period. I am able to save the file in documents directory.

But how to make it accessible from other apps.I am able to create .pdf files but when tried to view the same using Adobe Reader, the file is not listing.

Please share any ideas so that I can view the files that I am saving from my app to be accessed outside my app also.


I created an HTML file in app's documents directory. Within the app, I am listing all files that are saved by the user.

NSString *docsFolder = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES)[0];

NSString *filename = [docsFolder stringByAppendingPathComponent:[NSString stringWithFormat:@"statement_%@_%@_to_%@.html",[selectedAcct substringFromIndex:MAX((int)[selectedAcct length]-5, 0)],strFromDate,strToDate]];

NSError *error;
[html writeToFile:filename atomically:NO encoding:NSUTF8StringEncoding error:&error];

    if(error != nil){

        UIAlert ---> "Error Message"

    }
    else
    {

        UIAlert ---> "Success Message"

    }
1

There are 1 answers

0
Woodstock On

All applications written using the iOS SDK on iPhone are sandboxed. This effectively means that they run in their own space.

Currently it's not possible to share the apps documents folder specifically (with the exception of extensions).

Instead you should consider using the iCloud documents API.