Unless I’m mistaken, and I very well could be, what is he best way to handle an array of values when using Core Data for storage? Or even a set of values that whose number of values may change from one time to the next? You could obviously have an attribute for 5 sets, or 7 sets, or 19 sets etc. but this doesn’t seem right? What if you set the number of sets to be 6 and the user needed 8? There could always be a time when the user may need more sets than given. Suppose you could use a very large numbers of sets like 50 or 100 but again that doesn’t seem very efficient or even the right way to accomplish the task.
I normally use the “transformable” data type to persist arrays, dictionaries etc.
Thanks, fujilla. I’m not sure what you mean by transformable. Are referring to transient? I did a search and uncovered a method similar to what we did with the image. Essentially, you can wrap NSArray in NSData. NSData can then be put into Core Data. A concern I have with this is the order of the items put into the NSData wrapper. Does it maintain its order when unwrapped?
My current solution is to create a data string that holds my array style data. My custom class will know how to unwrap this string. Essentially, I’ll use NSRegularExpression. wonder what other may think of this method.
In your Core Date model, when you create attributes there is a data type called “transformable”. I use this data type to persist a collection of references to tracks from the users iPod in my first app Easy Intervals. There is also a Binary Data data type which may be of interest to you, depending on what your needs are.
If you are turning a NSArray into a NSData object I believe it should not change the order of the object inside of the array.
I hope that helps,
Thanks, Nick. I’ll look into those ideas.