Recently I implemented a new object type to be stored in Core Data. A very simply object: "LikedObjects" with one data type called "likedObjects". Here is a snippet from my Xcode project.
For whatever reason, saving the data did not work. It would ALWAYS return nil (when before implementing this it worked perfectly for the other, crossed-out entities).
SOLUTION:
I deleted and re-installed the app. Works fine. Changed 0 code.
My question:
Is it possible / a way for
CoreData
to corrupt? I want to know a potential reason for why deleting and reinstalling the app was a solution, so that if so I can prevent this in any way...
Yes it can. One of the reasons could be a line separator coming from a Windows app (CRLF) or an otherwise invisible character within the XCode editor, coming from copy & paste.
One way to get rid of these problems is moving the file outside the project and then add it as an existing file once again. The import/copy function does a decent job of cleaning unwanted code. If this does not help, then you will have to write a function which purges ASCII characters 0-26, exception made for code 11 (LF). If you have binary data though, it may not work!
Finally, a matching pair of keys and values may have gone havoc. There, you will have to paste one by one (pair), until you find the cause of grief.