Kernel Data Object Naming Convention

Is there a convention for naming a Core Data object? Argument I have heard that this is not the case for prefixing a Core Data object because there is no chance they will collide as they only have to be unique within the model, which is not correct since the generated NSManagedObject subclass may still collide with existing classes Objective-C.

So it seems logical to me to do two things for the Core Data Entity: prefix with my project class prefix and suffix it with Entity. This way I know this is a Core Data object and its name will never clash with other classes.


source to share

2 answers

I've actually seen both prefixes with and without a prefix. I've never seen a suffix added. I prefer no project prefix since if you have a remote database that you syncronized with, I would use the same entity names. And then, if you ever release a public API, do you really need a project prefix all over the place? For example, Stripe objects are Customer, Card, etc. They use a prefix on unique IDs which I like. Also, if you use the project prefix for other classes, you don't run the risk of overwriting, as you mentioned in your OP.



From here

You cannot give an accessor a name that starts with a new one. This, in turn, means that you cannot, for example, declare a property whose name starts with a new one unless another getter method is specified

And as far as I know, also the copy keyword cannot be used as a suffix.



All Articles