I have an entity called
. It has a to-many relationship to
I have a table view controller that displays all the
that are saved. When the user taps on one of the cells, a segue that goes to another table view controller is performed. That table view controller displays all the associated
subclasses that Xcode has generated for me, the
property is declared to be of type
. I know that sets don't maintain the order of its elements. This means that I might save the inputs in this order:
But when I fetch it back, I might get it in this order instead
but I want the inputs to be in the same order as they were saved!
How do I solve this problem?
I have thought of adding an
. Each time I save a new one, I increment the id. When I fetch it, I sort the array according to the id. But I am sure there's a better way to do it than this.
with brute force? That can't work, can it?
It is surprising that I have not found anyone asking the question on Stack Overflow!