2013-07-11 37 views

回答

3

我想通了!這些文件存儲在名爲「收件箱」的文件夾的子文件夾中。你需要在那裏刪除它們。這裏是代碼:

NSString *fileName = @"afile.png"; 
    NSString *documentsDirectory = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0]; 
    NSString *inboxDirectory = [documentsDirectory stringByAppendingPathComponent:@"Inbox"]; 
    NSString *filePath = [inboxDirectory stringByAppendingPathComponent:fileName]; 
    NSError *error; 
    BOOL success = [fileManager removeItemAtPath:filePath error:&error]; 
    if (!success) { 
     NSLog(@"error occured during removing the file"); 
    } 
+0

不要忘記你可以接受你自己的答案.... –

0

手動搜索收件箱在我看來不是一個很好的做法。如果我將文件發送到我的應用程序,則在完成處理後將其刪除,或者稍後需要時將其移至緩存/臨時目錄以防止iCloud將其備份。

func application(application: UIApplication, openURL url: NSURL, sourceApplication: String?, annotation: AnyObject) -> Bool { 
    processUrl(url) 
    removeFileAt(url) 

    return true 
} 
相關問題