我想寫一個非常簡單的數據到.plist文件,我已經檢查了各種代碼示例,但我很掙扎讓它起作用。試圖寫入.plist文件,但它不起作用
首先,有創建該文件本身並返回路徑的方法:
-(NSString *)getFilePath{
NSArray *thePath = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
return [[thePath objectAtIndex:0] stringByAppendingPathComponent:@"events.plist"];
}
然後,這是我已經迷上了一個按鈕的動作。它現在只插入一行虛擬數據。或者至少,這就是我想要做的。
- (IBAction)saveData:(id)sender {
NSArray *data = [[NSArray alloc] initWithObjects:@"E3 Expo", @"05-06-2012", nil];
[data writeToFile:[self getFilePath] atomically:YES];
}
但它不起作用。我通過Xcode中的管理器檢查了用戶文檔的目錄,並且沒有在「文檔」文件夾中創建任何內容。
任何幫助,將不勝感激。 :)
的Plist是NSDictionarys ... – CodaFi