Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/43.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Iphone 将选中标记的行保存到appsettings中。编辑_Iphone_Cocoa Touch_Uitableview - Fatal编程技术网

Iphone 将选中标记的行保存到appsettings中。编辑

Iphone 将选中标记的行保存到appsettings中。编辑,iphone,cocoa-touch,uitableview,Iphone,Cocoa Touch,Uitableview,编辑:我得到了一个保存,现在它不工作 NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; [defaults setObject:countries forKey:@"country"]; [defaults synchronize]; 储蓄 但是我想我必须从appsettings加载数组。怎么做 现在我明白了: countries = [[NSArray alloc] initWithObjects:@"Al

编辑:我得到了一个保存,现在它不工作

NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
[defaults setObject:countries  forKey:@"country"];
[defaults synchronize]; 
储蓄

但是我想我必须从appsettings加载数组。怎么做

现在我明白了:

countries = [[NSArray alloc] initWithObjects:@"All",@"Austria",@"Belarus",@"Canada",@"Czech Republic",@"Denmark",@"Germany",@"Finland",@"France",@"Latvia",@"Norway",@"Russia",@"Slovakia",@"Slovenia",@"Switzerland",@"Sweden", @"USA", nil];
使用NSUserDefault的同步方法


谢谢你的回复。我不知道你写了什么,但它不起作用。我想我必须从默认值中读取数组?如何读取电流?
 - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
    {
        int newRow = [indexPath row];
        int oldRow = (lastIndexPath != nil) ? [lastIndexPath row] : -1;

        if (newRow != oldRow)
        {
            UITableViewCell *newCell = [tableView cellForRowAtIndexPath:
                                        indexPath];
            newCell.accessoryType = UITableViewCellAccessoryCheckmark;

            UITableViewCell *oldCell = [tableView cellForRowAtIndexPath: 
                                        lastIndexPath]; 
            oldCell.accessoryType = UITableViewCellAccessoryNone;
            lastIndexPath = indexPath;
        }
        NSUInteger row = [indexPath row];
        NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
        //Suppose you have used **myArrayUsedInTableView**   Array to construct TableView 
        ..................................................................................
        ............./*Do changes here in myArrayUsedInTableView  as per your requirement*/
        ....................................................................................
        //Now store your array myArrayUsedInTableView in NSUserDefault
        [defaults setObject:myArrayUsedInTableView  forKey:@"StoredArray"];
        [defaults synchronize]; 
        [tableView deselectRowAtIndexPath:indexPath animated:YES];
  }