Really weird problem.
I have a tableView that pulls data out of a Core Data database and orders it by date. Everything’s working fine, but I want to be able to rearrange the order of the tableView and make it persist. I read a number of threads here about it, so I tried “swapping” the date attributes of the managedObject at fromIndexPath and the managedObject at toIndexPath.
Then it got weird. It worked the first couple of times. Then it kind of got out of order. Then the table started to show up strangely. Entries would duplicate and appear and disappear. When I exited edit mode, half the items would still be in edit mode, and when it tried to delete those, the app crashed (sent delete to a nil object). I tried it again using NSNumber instead of NSDate and the same thing happened.
I’m just learning how to use Core Data so I’d love to know what is causing this really weird behaviour, if anyone could venture a guess. Why wouldn’t something as simple as changing attributes just work? Could it have something to do with the tableView having cached data? (When I told the tableView to reloadData after every swap, it just wouldn’t swap at all!)
A solution to the problem would also be awesome, but I’m sure it’s out there, I just have to do more googling when I get the time.
This is an iOS 5 bug that’s been fixed.