AwakeFromFetch with an unmanaged property

I have a subclass of NSManagedObject with some image data in the NSData ( imageData ) imageData , which is automatically saved. After downloading the data from the network, I also set my own NSImage ( image ) property with the image created from the data.

The problem is that if the object is an error, awakeFromFetch is not called when I access the image property, since it is not processed by Core Data. I can, of course, override the image accessory and make sure that the properties are loaded (by accessing imageData ), but it would be nice if awakeFromFetch were called as usual. Any suggestions?

+4
source share
2 answers

As suggested by TechZen, I am now executing a select query with returnsObjectsAsFaults set to NO . Of course, this is not an ideal way to pull all the data from the cache every time an object is retrieved, but in my case, I always use the data immediately to make it acceptable.

+2
source

It seems you want to do two conflicting things, you want the main object to remain guilty, but have the ability to access its attributes. You cannot do this. An error by definition does not have attributes / properties, because it is just a placeholder in the object graph. If you want your main object to remain faulty, you must move the UIImage to your own entity and associate it with the main object. You can then go through the graphic to get a UIImage without causing the loading of the main location of the damage to the object.

0
source

Source: https://habr.com/ru/post/1345346/


All Articles