开发者

Store data from TableView in the NSUserDefaults

开发者 https://www.devze.com 2023-02-18 22:24 出处:网络
if got a tableview and the user can add strings into it: -(IBAction)textFieldDidEndEditing { NSString *string = textField.text;

if got a tableview and the user can add strings into it:

-(IBAction)textFieldDidEndEditing {

NSString *string = textField.text;
[tableAr开发者_高级运维ray addObject:string];
[mainTableView reloadData];
textField.text = @"";

}

how can I store the content of the tableView into the NSUserdefaults? can anybody give me a short example please?

thanks :)


try storing whole Array as an Object into NSUserDefaults

NSUserDefaults *default = [NSUserDefaults standardUserDefaults];

[default setObject:tableArray forKey:@"key"];

& now to fetch it from NSUserDefautls:

NSArray *array = [standardUserDefaults objectForKey:@"key"];

Hope this solve some sort of problem of urs. :)

0

精彩评论

暂无评论...
验证码 换一张
取 消