2
2つの配列のデータをドキュメントディレクトリに保存する必要があります。最初のものは保存されましたが、2番目のものは保存されませんでした。2 NSArrayデータをNSDocumentDirectoryの2つのファイルに保存します
- (void)viewWillDisappear:(BOOL)animated
{
[super viewWillDisappear:animated];
NSString *documentsDir = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) firstObject];
NSString *rangePath = [documentsDir stringByAppendingPathComponent:@"Range.plist"];
NSString *indexPath = [documentsDir stringByAppendingPathComponent:@"Select.plist"];
[finalMutable writeToFile:rangePath atomically:YES];
[finalIndex writeToFile:indexPath atomically:YES];
}
は更新:finalIndexアレイがNSIndexPath objects.NSIndexPathオブジェクトはのplistファイルに保存することはできません含まれているため
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
[finalIndex addObject:[NSIndexPath indexPathForRow:indexPath.row inSection:indexPath.section]];
}
PLSがfinalMutableとfinalIndexが含まれていないものを追加し、finalIndexは、彼らの両方が同じ持っている問題 –
でなければなりませんこれはNSLog:finalMutableカウント:5、finalIndexカウント:5 –