3
我無法弄清爲什麼我的iPhone應用程序中的文件似乎仍然存在,即使刪除了它們。這是給我麻煩的代碼:爲什麼我的iPhone NSBundle文件夾中的文件不能被刪除?
NSFileManager *fileManager = [NSFileManager defaultManager];
NSString *bundlePath = [[NSBundle mainBundle] bundlePath];
NSString *folderPath = [bundlePath stringByAppendingPathComponent:@"filefolder"];
NSArray *fileNames = [fileManager contentsOfDirectoryAtPath:folderPath error:NULL];
此代碼應該查看文件夾「filefolder」並將其內容讀入fileNames中。當我第一次運行這個應用程序時,它會執行此操作。但是,如果我更改filefolder的內容(例如,如果我添加或刪除文件),然後再次構建並運行應用程序,則數組文件名將包含所有新添加文件的名稱(好),但也包含所有文件的名稱應該被刪除(壞)!
任何人都可以幫助我理解爲什麼我看到這種行爲?
This worked for me http://stackoverflow.com/questions/8000881/cant-remove-files-from-mainbundle – Krishnan 2013-12-06 13:04:16