Why NSFetchedResultsController is not being updated with new data?

前端 未结 4 821
我在风中等你
我在风中等你 2021-01-18 05:33

My Core Data model has two entities: Author and Book with a To-Many relationship (one author->many books). In the main view I display a list of

4条回答
  •  忘掉有多难
    2021-01-18 05:57

    Why don't you commit the transactions saving changes?

    - (void)saveAuthorName:(NSString *)newName {
        for (Book* book in author.books) {
            [book willChangeValueForKey:@"author"];
        }
    
        author.name = newName;
    
        for (Book* book in author.books) {
            [book didChangeValueForKey:@"author"];
        }
        NSError * error ;
        if( ![self.moc save:&error] ) {
             ..... do something ..
        }
    }
    

提交回复
热议问题