[NSManagedObjectContext delete:]: unrecognized selector sent to instance

前端 未结 2 954
说谎
说谎 2021-01-19 12:57

core data getting on my nerves. i\' m deleting old data and want to insert new data received from server.

now the deleting part gives a \"sigabort\":

2条回答
  •  南笙
    南笙 (楼主)
    2021-01-19 13:17

    do it like this for deleting an object permanently

    for (TEventContact *tmpCon in allCons)
    {
        [context deleteObject:tmpCon] /// for deleting object in context
    }    
    [context save]; /// to reflect changes in database you need to save that context
    

    without saving the context it doesn't reflect on data base and that may cause DIRTY_READ for another context

提交回复
热议问题