this sounds like such a rudimentary question, but I'm trying to tarck down a problem and it keeps looping back to this.
a sketch of what I am doing:
I have an array, then I add an array to that array using the insert(contents of: method (which allows you to insert an entire array at an index.)
then somewhere downstream these elements are laid out (it's a graphics thing)
in order to lay out the items in the array, the first thing I do is filter the array, excluding elements that are laid out separately. I use the filter method:
array.filter({$0 is MyClass}) // something like that
then I layout the graphics. it's a top down layout. I start at the top of the workspace, and I increment the position of the frame of the element, subtracting the height from the y position...
newPosition = CGPoint(x: 0, y: lastPosition.y - thisItem.frame.height) // that sort of thing.
so, I rely heavily on the order of the items... not changing. But it seems to do exactly that. Now, I have a few other things to track down... this is more likely some kind of transposition error in figuring out the "real world" index to insert the new items, but it brings up a more pressing and generalised concern. I have to be certain about Arrays... is there any effort to maintain the order in an array? including when run through methods that return Other arrays such as filter?