2017-07-15 10 views
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]]; 
} 
+0

PLSがfinalMutableとfinalIndexが含まれていないものを追加し、finalIndexは、彼らの両方が同じ持っている問題 –

+0

でなければなりませんこれはNSLog:finalMutableカウント:5、finalIndexカウント:5 –

答えて

1

あなたは、2番目のファイルを保存することができません。 PLISTでサポート データタイプは次のとおりです。 アレイ、 辞書、 文字列、 番号、 データ、 日、 ブール

関連する問題