Closed itsthejb closed 10 years ago
I still haven't figured this out yet but I hope to find some time today and check if this introduces any side effects in our own projects. But I think forcing an existing object definitely makes sense and prevents possible bugs.
I just pushed 1.7.1. Thank You very much :)
Great, thanks @OliverLetterer
Hi Oliver,
Think I may have just got to the root of an issue I've been having for quite a while: I have some quite complex entities that need to see up transient properties and various kinds of observation in a reliable fashion, and I'm doing this using the
NSManagedObject
life-cycle methods,awakeFromInsert
,awakeFromFetch
, etc.However, I had been having the issue that these methods weren't being called from the main thread context. They certainly were from the background thread, but not when the object was inserted into the main context.
Just investigating further, in
managedObjectCollector()
I did my own experimentation and found that using
objectWithID:
won't call the life-cycle methods if it's called on a main context (for example) when the entity was originally inserted into a child context and that context wasn't first saved. UsingexistingObjectWithID:error:
is more helpful in this case since you get a clearAttempt to access an object not found in store.
error. After a save, the life-cycle methods are called as expected.In the case of
SLRESTfulCoreData
, I'm not sure the issue is exactly the same, however with the following patch b5cca4790fc262a38d92f306eb0be6c9afd05ead, I seem to get the lifecycle methods triggered as expected.In any case, please let me know what you think about this.
Thanks!