ioscore-datamogenerator

How do you mark a property as 'readonly' for CoreData?


We have an application which I am updating, which also involves reorganising and flattening a CoreData model. Everything builds fine, but when I try to set some of the properties in CoreData, it complains that the properties in question are set to 'read only' and that no setter method can be generated.

No matter where I look, I can't find any place in the Core Data modeller to mark the property as such, nor can I find out if mogenerator generated it this way on purpose.

Does anyone know where the property is marked as 'readonly'?

Update

I've figured out the problem and it has nothing to do with either Core Data or with mogenerator. It actually has to do with the fact that it had a protocol defined which had the same name property marked as readonly. The reason this only pops up now is mentioned in this SO question as well. I've removed the extra info about syncservices which might confuse people.

I'll be adding an answer which notes the only way I know of setting a Core Data object to readonly with mogenerator, since that's an answer to this question. Any other methods to do this can still be answered as well.


Solution

  • The problem had nothing to do with Core Data or with mogenerator. See my updated question for details.

    That said, mogenerator does provide a method to mark Core Data entity properties as readonly by adding the User Info key (with any value):

    mogenerator.readonly
    

    This is mentioned in the v1.27 change history on github as well.