Question

I'm using a project find on github that lets me use NSFetchedResultsController and UICollectionView, the project is this

but when I save a new object like in this way:

NSManagedObject *doc = [NSEntityDescription insertNewObjectForEntityForName:@"Document" inManagedObjectContext:self.managedObjectContext];
                    [doc setValue:[title contents] forKey:@"docName"];
[doc setValue:element valueforKey:@"Element"]

[self saveContext];

I receive this error:

 CoreData: error: Serious application error.  Exception was caught during Core Data change  processing.  This is usually a bug within an observer of NSManagedObjectContextObjectsDidChangeNotification.  Can't perform collection evaluate with non-collection object. with userInfo (null)

I have tried to remove that project, and the save works, so I think the problem in that project, any help?

No correct solution

OTHER TIPS

I would recommend that you export the NSManagedObject subclass and declare your object as that follows:

// At top of the file:
#import "Document.h"

// In your Method:
Document *doc = (Document *)[NSEntityDescription insertNewObjectForEntityForName:@"Document" inManagedObjectContext:self.managedObjectContext];
doc.docName = title.contents;

NSError *error = nil;
[self.managedObjectContext save:&error];

if (error != nil) {
    NSLog(@"Oh no! Something terrible happened! Error: %@", error);
}
else {
    NSLog(@"Saved! Yay!");
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top