2010-11-05 8 views
3

Lorsque j'ai enregistré un fichier PDF dans un fichier en utilisant une URL, le fichier PDF enregistré n'apparaît pas dans la fenêtre de document Itunes/My iPad name/Apps/MyApp. En fait, je ne vois même pas mon application dans la section Partage de fichiers. Comment une application comme "dropbox" ou "pages" le fait-elle?Développement ios: Le fichier enregistré n'apparaît pas dans iTunes

code utilisé
// url du pdf Je veux
NSURL *pdfURL = [NSURL URLWithString:@"http://manuals.info.apple.com/en/iphone_user_guide.pdf"];

// Obtenez le chemin de notre répertoire documents
NSArray *documentPath = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);

// Cela devrait être nos documents annuaire
NSString *saveDirectory = [documentPath objectAtIndex:0];
NSString *saveDirectory2 = [[saveDirectory stringByAppendingPathComponent:@"myfile.pdf"] retain];

// convertir mon PDF en NSData, peut-être que je ne peux pas convertir m un PDF?
NSData *dataToWrite = [NSData dataWithContentsOfURL:pdfURL];

// écrit le pdf converti dans la mémoire à chemin
BOOL status = [dataToWrite writeToFile:saveDirectory2 atomically:YES];

Répondre

0

Dans la nouvelle Xcode, vous pouvez le faire dans l'interface utilisateur:

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