I am working on an iPhone app and have an entity set up in coredata that has two attributes
- text
- order
The user can take a photo for each object in the entity. As a proof of concept, I am saving the photo using the entites ‘text’ attribute in the documents folder.
I tried getting the object ID using: [object objectID], but that gives me a string full of guff, eg:
<x-coredata://791282FC-9A08-451F-9348-1B972E8A144D/Articulation/p5>
My idea was to add another attribute ‘id’ to the entity that autoincrements and use that id as the filename of the photo (there will only ever be one photo per entity).
Is that considered bad practice? And if so, what should I be doing?
Thanks,
James.
I would create an attribute
imageFileNamein the entity, and store the file name of the image there.That way, you can implement what you want to do now (by autogenerating
imageFileNameby incrementing an internal counter),or you can let the user name the image, if you later change your mind.
It is non-trivial to change the CoreData schema once you ship your app. So I prefer to keep a bit of room in the schema so that I can change the behavior of the program without changing the schema.