The Lazy Hiker
The Lazy Hiker

Reputation: 1563

ios development: Saved file does not show up in itunes

When i saved a PDF to a file using URL, the saved pdf does not show up in Itunes/My iPad name/Apps/MyApp's document window. Actually i dont even see my app under the File Sharing section. How is app like "dropbox" or "pages" do it?

Code used
//url of the pdf I want
NSURL *pdfURL = [NSURL URLWithString:@"http://manuals.info.apple.com/en/iphone_user_guide.pdf"];

// Get the path to our documents directory
NSArray *documentPath = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);

// This should be our documents directory
NSString *saveDirectory = [documentPath objectAtIndex:0];
NSString *saveDirectory2 = [[saveDirectory stringByAppendingPathComponent:@"myfile.pdf"] retain];

//convert my PDF in to a NSData, maybe I can't convert from a PDF?
NSData *dataToWrite = [NSData dataWithContentsOfURL:pdfURL];

//writing the pdf converted in the memory at path
BOOL status = [dataToWrite writeToFile:saveDirectory2 atomically:YES];

Upvotes: 3

Views: 1449

Answers (2)

ski_squaw
ski_squaw

Reputation: 1030

In the new Xcode, you can do this in the UI:

1. Select your project in top left
2. Select target in next column
3. Click on Info tab
4. In Custom iOS Target Properties, hover mouse over any row and click +
5. In popup, select "Application supports iTunes file sharing", then set Value to YES on right
6. Click Validate Settings at bottom to make sure all is good

Upvotes: 0

Ryan
Ryan

Reputation: 16636

Have you added the UIFileSharingEnabled key to your app's Info.plist file and set its value to YES, per the instructions here?:

http://developer.apple.com/library/ios/#documentation/General/Reference/InfoPlistKeyReference/Articles/iPhoneOSKeys.html%23//apple_ref/doc/uid/TP40009252-SW20

Without it, iTunes won't see what's in your app's Documents directory.

Upvotes: 2

Related Questions