我對此問題有更新。我能夠消除這個問題,但遺憾的是我不能100%確定我刪除了哪些文件,是問題的根源。不過,我想分享我的方法。
我很確定問題必須存在於應用程序文件夾的某處,否則它不會發生該應用程序在全新安裝後工作,但不會在更新時發生。
我決定比較我的應用程序內的文件系統,當做一個乾淨的安裝或更新後的這個損壞的版本。我決定遍歷應用程序的文件夾並打印出文件。清除緩存之前和之後。我下面的代碼添加到我的AppDelegate
比較:
NSArray *paths = [NSArray arrayWithObjects:
[NSNumber numberWithUnsignedInt:NSApplicationDirectory],
[NSNumber numberWithUnsignedInt:NSAutosavedInformationDirectory],
[NSNumber numberWithUnsignedInt:NSDesktopDirectory],
[NSNumber numberWithUnsignedInt:NSCachesDirectory],
[NSNumber numberWithUnsignedInt:NSApplicationSupportDirectory],
[NSNumber numberWithUnsignedInt:NSDownloadsDirectory],
[NSNumber numberWithUnsignedInt:NSInputMethodsDirectory],
[NSNumber numberWithUnsignedInt:NSMoviesDirectory],
[NSNumber numberWithUnsignedInt:NSMusicDirectory],
[NSNumber numberWithUnsignedInt:NSPicturesDirectory],
[NSNumber numberWithUnsignedInt:NSPrinterDescriptionDirectory],
[NSNumber numberWithUnsignedInt:NSSharedPublicDirectory],
[NSNumber numberWithUnsignedInt:NSPreferencePanesDirectory],
[NSNumber numberWithUnsignedInt:NSItemReplacementDirectory],
[NSNumber numberWithUnsignedInt:NSAllApplicationsDirectory],
[NSNumber numberWithUnsignedInt:NSAllLibrariesDirectory],
nil];
NSFileManager *manager = [NSFileManager defaultManager];
for (NSNumber *directory in paths) {
NSArray *tp = NSSearchPathForDirectoriesInDomains([directory unsignedIntegerValue] , NSUserDomainMask, YES);
if ([tp count] == 0)
continue;
NSString *path = [tp objectAtIndex:0];
NSDirectoryEnumerator *direnum = [manager enumeratorAtPath:path];
NSString *filename;
NSLog(@"-------------------------------------------------------");
NSLog(@"== path: %@", path);
NSLog(@"-------------------------------------------------------");
while (filename = [direnum nextObject]) {
NSString *thefile = [NSString stringWithFormat:@"%@/%@", path, filename];
NSLog(@"\t%@, deletable? %d", filename, [manager isDeletableFileAtPath:thefile]);
}
}
我則比較輸出,並發現該文件只留下住在NSAllLibrariesDirectory
。也就是說,他們
Cookies/Cookies.binarycookies
Preferences/.GlobalPreferences.plist
Preferences/com.apple.PeoplePicker.plist
Preferences/com.medienhaus.VOL.plist
在這裏,我epically失敗並實施了結算方法來刪除,而不是一個會接一個地找出哪個文件導致問題的文件。
所以,現在我有一個工作版本,但我不知道這四個文件中的哪一個會破壞它。最有可能的是Cookies.binarycookies
。
你有什麼想法可以在其他地方?我在'/Library/Caches'中找到了一些文件,並清除了它(似乎也清除了Three20的緩存,這應該是所有應用程序直接或間接的地方(有些東西顯然是由iOS自動編寫的)創建文件AFAIK。爲了確保我也檢查了各種其他文件夾(文檔,應用程序支持,下載)文件,可能會給我一個提示,但什麼也沒找到。有沒有辦法列出所有與我的應用程序相關的文件? –
mwidmann
2012-03-28 18:34:25
@mwidmann對不起,但我沒有具體的知識可以幫助你,雖然我自己是一個iOS新手,但我一直給出基於故障查找軟件系統一生職業生涯的一般建議。到一個應用程序聽起來像一個偉大的SO問題! – 2012-03-28 18:46:27