0

チェックマークが付いた長いリストの設定ページがあります。ユーザーは必要な数の行を選択でき、NSUserDefaults に保存しています。次回設定を開くときに以前の選択を選択したいので、これを試しました:

NSArray *array = [NSMutableArray arrayWithArray:[[NSUserDefaults standardUserDefaults] objectForKey:@"choices"]];

if (array.count !=0) {
    NSLog(@"not empt");
    for (id obj in array) {
        NSIndexPath *path = [NSIndexPath indexPathWithIndex:obj];
        [self.tableView selectRowAtIndexPath:path animated:NO scrollPosition:UITableViewScrollPositionTop];
    }

}

しかし、アプリは毎回このエラーでクラッシュします:

erminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Invalid index path for use with UITableView.  Index paths passed to table view must contain exactly two indices specifying the section and row.  Please use the category on NSIndexPath in UITableView.h if possible.

私は何を間違っていますか?ありがとう

4

1 に答える 1