2017-07-15 5 views
2

Je dois enregistrer des données de 2 tableaux à document dir, le premier a été enregistré, mais le second pas !!Enregistrer 2 données NSArray à 2 fichiers dans NSDocumentDirectory

- (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]; 

} 

mise à jour:

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
    [finalIndex addObject:[NSIndexPath indexPathForRow:indexPath.row inSection:indexPath.section]]; 
} 
+0

Pls ajouter ce ne finalMutable et finalIndex contient, finalIndex doit être un problème –

+0

Ils ont tous deux même, c'est NSLog: final Nombre de comptes: 5, nombre de finalIndex: 5 –

Répondre

1

Vous ne parvenez pas à enregistrer le fichier 2, car finalIndex tableau contient des objets NSIndexPath objects.NSIndexPath ne peuvent pas être stockées dans des fichiers plist. types de données pris en charge dans plist sont: Array, Dictionnaire, String, Nombre, données, Date, Boolean