I have a UITableView that when scrolled to far bounces bag. This also means the user can drag the table so that only half of it is visible and the other half of the main view is white. This causes some weird behavior in my app. I create an array in the AppDelegate. In RootViewController's viewDidLoad, I get a reference to the AppDelegate and keep it around until the app shuts down. In RootViewController's cellForRowAtIndexPath, I reference the AppDelegate instance's array to get objects that will fill cell labels. That works fine until the user scrolls as mentioned above. Once that happens, in can see in the debugger that object 7, for instance, in the array has turned into UICachedDeviceRGBColor. I have no idea why that happens. The array is only assigned once in AppDelegate on app creation. It is only read referenced from then on.
From what I can tell, I must first click a row in the table. The new view is pushed, which also has a UITableView. in the cellForRowAtIndexPath of this 2nd view, I check the delegate.array, since 2nd view also has a reference to the array. I immediately see that object 2 in the array is:
2 : UIDeviceRGBColorSpace 1 1 1 1
which it shouldn't be. Then when I click back and the main table displays again, do the above scroll technique to get the weirdness. I scroll the table just enough to hit my breakpoint in cellForRowAtIndexPath and see the array has been altered. Object two is the correct type but now object 7 isn't.
The problem is that if I try to access object 7 and call a property on the type I'm casting to, that property of course doesn't exist on UICachedDeviceRGBColor. It's an "Inavlid" and so I get the “EXC_BAD_INSTRUCTION" because of bad memory access.
What causes this alter of the array under this specific condition? Or at the least, how can I guard against it?