NSObjectInaccessibleException', reason: 'CoreData could not fulfill a fault

后端 未结 5 1776
野性不改
野性不改 2021-02-15 14:27

My iOS app uses core data via multiple threads. I am getting some crash reports with the following message: \"\'NSObjectInaccessibleException\', reason: \'CoreData could not ful

5条回答
  •  礼貌的吻别
    2021-02-15 14:54

    You could try and use existingObjectWithID:error::

    Returns the object for the specified ID.

       - (NSManagedObject *)existingObjectWithID:(NSManagedObjectID *)objectID error:(NSError **)error
    

    Discussion

    If there is a managed object with the given ID already registered in the context, that object is returned directly; otherwise the corresponding object is faulted into the context.

    This method might perform I/O if the data is uncached.

    Unlike objectWithID:, this method never returns a fault.

    You could dO:

    if ([myMOC existingObjectWithID:myObject.objectID error:&error])
        ...
    

提交回复
热议问题