我正在为核心数据使用父/子上下文。对象被添加到后台线程和上下文中。效果很好。对象也会在后台上下文中删除并保存在子/父上。我可以看到在核心数据调试中,对象被删除并成功提交。之后我告诉 nsfetchresultcontroller(设置为 nil 并重新初始化和删除缓存)来获取对象。即使对象被删除,对象仍然存在。
CoreData: sql: COMMIT
CoreData: sql: BEGIN EXCLUSIVE
CoreData: sql: INSERT INTO ZTLOG(Z_PK, Z_ENT, Z_OPT, ZFXY, ZFXYZ) VALUES(?, ?, ?, ?, ?)
CoreData: sql: COMMIT
删除
CoreData: sql: BEGIN EXCLUSIVE
CoreData: sql: DELETE FROM ZTLOG WHERE Z_PK = ? AND Z_OPT = ?
CoreData: sql: COMMIT
nsfetchresult 控制器
CoreData: annotation: fetch using NSSQLiteStatement <0x68a2760> on entity 'TLog' with sql text 'SELECT 0, t0.Z_PK, t0.Z_OPT, t0.ZXY, t0.ZXYZ WHERE t0.Z_PK = ? ' returned 0 rows
CoreData: annotation: total fetch execution time: 0.0080s for 0 rows.
CoreData: annotation: fault fulfilled from database for : 0x687ab40 <x-coredata://BCA24D29-F9D3-4068-8122-E7A43C116D8A/TLog/p2>
所以即使我将 fetchcontroller & delegate 设置为 nil 并重新初始化,表视图仍然有对象。但 fetchresult 控制器 fetchedobjects 仍然删除了对象。最后一个日志行看起来很可疑。我删除了所有对象。为什么它完成了错误?
有人知道吗?