0
我正在創建一個將值插入tableview的應用程序。我還想在將值添加到表格時添加時間戳。該場景將是:如何在UITableView中添加和存儲數據?
- 我在文本字段中寫入一些隨機文本。
- 我按下按鈕
- 文本字段中的文本與我點擊按鈕的時間一起保存在表中。
- 完成。
我正在創建一個將值插入tableview的應用程序。我還想在將值添加到表格時添加時間戳。該場景將是:如何在UITableView中添加和存儲數據?
根據數據的大小,可以將它存儲在plist或sqlite3中。 這裏有可能是有用的鏈接: http://www.bogotobogo.com/XcodeSDK-Chapter10.html
(NSString *)dataFilePath {
NSArray *paths = NSSearchPathForDirectoriesInDomains(
NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
return [documentsDirectory stringByAppendingPathComponent:kFilename];
}
(void)applicationWillTerminate:(NSNotification *)notification {
NSMutableArray *array = [[NSMutableArray alloc] init];
[array addObject:field1.text];
[array addObject:field2.text];
[array addObject:field3.text];
[array addObject:field4.text];
[array writeToFile:[self dataFilePath] atomically:YES];
[array release];
}
謝謝!我會檢查一下。 – jaytrixz