I have a mutable array and i would like to arrange it in a nested order upon some criteria. To achieve this I'd like to move certain elements to mutable arrays of another elements, removing them from the main mutable array, but without releasing them. Actually the question is about removing elements from array without releasing them How do i achieve it?
Thanks
You cannot remove an object from an array without the array releasing it. If you want to make sure it sticks around, just retain it yourself first, and release it when you're done. These are pretty cheap operations, so you shouldn't worry too much about it.
Since you're moving items from one array to another, it would be easier if you first added the object to the new array and then removed it from the original array.
This is faster than retaining it, removing it from the array, adding it to the new array and then releasing it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With