开发者

Executing a fetch request inside prepareForDeletion not allowed?

This is as much a question as it is a warning; I had a bug in my app which I finally tracked down to the following: inside prepareForDeletion of some NSManagedObject subclass I was accessing an array which was created on demand by executing a fetch request. If that array was开发者_如何学编程 already there when prepareForDeletion was called (and hence when no fetch request was necessary) everything worked fine, but if the array had not yet been loaded and the fetch request was executed, it seemed that the delete of the object-about-to-be-deleted was actually completed when the fetch was executed, making it impossible for prepareForDeletion to complete its task. I couldn't find anybody else complaining about this, however, nor any mention of it in the documentation, so perhaps it's something else. I'm curious if somebody else has seen this behaviour.


I also encountered this behaviour of executing fetch request in prepareForDeletion. It is frustrating why it happens. And also I found that prepareForDeletion will be called twice. First time when deleteObject: is called. Second time is when save operation is performed.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜