How to delete iCloud documents?

icloud, ios, iphone

Solution

To delete the document from iCloud, first you have to get the filename you want to delete. and then you can delete it using NSFileManager.

NSString *saveFileName = @"Report.pdf";
NSURL *ubiq = [[NSFileManager defaultManager] URLForUbiquityContainerIdentifier:nil];
NSURL *ubiquitousPackage = [[ubiq URLByAppendingPathComponent:@"Documents"] URLByAppendingPathComponent:saveFileName];
NSFileManager *filemgr = [NSFileManager defaultManager];
[filemgr removeItemAtURL:ubiquitousPackage error:nil];

This is the way, which i used to delete document, Check it out. It is woking great for me. Thanks

Problem

I'm using a UIDocument with iCloud. I'm not using CoreData. What's the best way to delete a UIDocument?

Original source