1

I want to import data from my iPhone to my application . up till now i have successfully imported Photo Library and music , but i also want to import pdf and other documents in my iOS app? How can i do that?

Hassan Malik
  • 559
  • 6
  • 20

3 Answers3

0
    NSString *bundlePath = [[NSBundle mainBundle] resourcePath];
    NSFileManager *mgr = [[NSFileManager alloc] init];

    NSArray *allFiles = [mgr contentsOfDirectoryAtPath:bundlePath   error:NULL];
    for (NSString *fileName in allFiles)
    {
        if ([[fileName pathExtension] isEqualToString:@"pdf"])
        {
            NSString *fullFilePath = [bundlePath stringByAppendingPathComponent:fileName];
            // fullFilePath now contains the path to your pdf file
         //   DoSomethingWithFile(fullFilePath);

            NSLog(@"file: %@",fullFilePath);

        }
    }

    NSURL *url = [[NSBundle mainBundle] URLForResource:@"" withExtension: @"pdf"];

    NSLog(@"File: %@",url);
MrWaqasAhmed
  • 1,479
  • 12
  • 12
  • Sir i need PDF and document of my devices not of my project directory , like if i want any photo to import in my app it open photoLibrary and i pick item from there. same if a pdf is running on ibook that i sync through i tunes i want that in my app to import – Hassan Malik Sep 04 '15 at 16:02
  • May be this will help you http://stackoverflow.com/questions/2594321/how-do-i-launch-ibooks-e-reader-programmatically-on-ipad – MrWaqasAhmed Sep 10 '15 at 06:55
0

You can't do it in iOS 8 (I haven't checked 9 though). You can't even enlist your app (adding corresponding URL schemes) in the sharing menu of iBooks.

user1232690
  • 481
  • 5
  • 16
0

You have to associate your app with the PDF types which you want to open. You can do this by adding some parameters to your Info.plist.

There's a well-answered post which explains this:

How do I associate file types with an iPhone application?

You should also consider reading Apple's documentation and a blog post written by me.

Community
  • 1
  • 1
Hemang
  • 26,840
  • 19
  • 119
  • 186