Question

I have an app which uses Core Data. My app does some processing in background threads and saves the output to Core Data, and simultaneously, my main/UI thread performs reading operations on Core Data.

Now, I am trying to synthesize one attribute in my managed object in order to create custom getters and setters (I wanna automatically save long strings in a file, and then simply save the path instead). But then, when reading these objects later in the main thread, they became nil. I tried removing my custom getters and setters and simply leaving @dynamic attr replaced with @synthesize attr = _attr, but even then it stopped working. (I cleaned my project and removed it from both the simulator and the devices I have been trying it out on).

The moment I restored the original syntax, everything started working once again. Any idea what could be causing such behavior?

Was it helpful?

Solution

Refer to Managed Object Accessor Methods section of Core Data Programming Guide for the information on how to correctly implement custom accessor methods.

By the way, in general it is recommended not to override managed object’s accessor methods because the existing implementation is highly optimized.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top