I have an array of objects and each object contains another array. How do I copy the array within the object? Using NSCopying I have been able to copy the object but the array within it will not copy.
Hi John, @jport1130
To give you a truer understanding of the problem, it is a distinction between Shallow Copy and Deep Copy. That is the issue here. Since everything (in computer terms) is a memory pointer that holds an address to the memory where the data is stored, not everything is copied/duplicated.
Apple docs suggest using NSCoding for a true deep copy of objects.
I will try to find some more detailed information for you.
You can read a bit more on Copying Collections
P.S. I am trying to provide you a way to post your project to allow someone(me as in your other question) to have a look at it.
cheers,
Jayant
@jport1130. Thanks very much for your question! I found the following link. So in your case, I would perhaps try to make your array conform to the NSCopying protocol, and continue with the steps outlined in the link above.
@jayantvarma I apologize in advance, as I’m not trying to step on your toes here.
I hope this helps!
All the best!
This topic was automatically closed after 166 days. New replies are no longer allowed.