1
我有以下代碼。它不會生成錯誤,但我的文件也不會更新。文件寫入問題
if([cDate compare:Today] == NSOrderedAscending){
NSLog(@"%@", [NSString stringWithFormat:@"%@, 0", Today]);
if(![[NSString stringWithFormat:@"%@, 0", Today] writeToFile:filePath atomically:TRUE])
NSLog(@"writeToFile failed");
}
filePath指向哪裏?它需要是一個可寫目錄,例如Documents目錄 - 而不是應用程序包。 – InsertWittyName
所以我們可以假設外層if是真的?第一個NSLog被寫入? – iandotkelly
文件路徑設置爲:NSString * filePath = [[NSBundle mainBundle] pathForResource:@「info」ofType:@「txt」];是的,我假設如果該方法返回一個true,該文件被寫入。這是一個錯誤的假設? – saman01