CoreData could not fulfill a fault for

后端 未结 5 812
我在风中等你
我在风中等你 2021-01-30 13:45

I have a really annoying problem, which I just can\'t seem to get fixed.

I have a view when I send a message that gets saved to the Core Data, when thats done it asked

5条回答
  •  隐瞒了意图╮
    2021-01-30 14:04

    It is not really conceptually possible to "save" Core Data objects "in different rows". Remember, Core Data is an object graph and not a database.

    If you want to "relocate" your sentence, the best way is to destroy it and recreate it. If you want to keep the old instance, just create a new one and then fill in the properties from the existing one.

    For destroying, use

    [self.context deleteObject:sentenceObject];
    

    For recreating, use

    Sentence *newSentence = [NSEntityDescription insertNewObjectForEntityForName:
      "Sentences" inManagedObjectContext:self.context];
    newSentence.sentence = sentenceObject.sentence;
    // fill in other properties, then
    [self.context save:error];
    

    If you would like to read up on this, look at "Copying and Copy and Paste" in the "Using Managed Objects" section of the "Core Data Programming Guide".

提交回复
热议问题