ashfurrow / yourfirstswiftapp

https://leanpub.com/yourfirstswiftapp
MIT License
66 stars 12 forks source link

Fix cell reordering glitches by disabling UIFetchedResultsControllerDelegate. #5

Open AndrewBennet opened 8 years ago

AndrewBennet commented 8 years ago

There are some weird UI glitches which occur currently - see this screen recording. Additionally, the userReordingCells boolean is not being used correctly. Things work much better if the fetchedresultscontroller delegate is disabled whilst rows are being moved.

AndrewBennet commented 8 years ago

Another change! It seems that changes to the order of objects in fetchedResultsController.sections?[sourceIndexPath.section]?.objects is not preserved. So if you perform multiple move operations, the new sort indexes will be calculated based on the original positions of the objects.

I.e. swap the top two rows, and then swap them back. At this point, the sort indexes of the managed objects do not match that of the table rows!

If you refetch after saving the managed object context, the ordering of the objects within fetchedResultsController.sections?[sourceIndexPath.section]?.objects is updated, and so subsequent moves are handled correctly.

ashfurrow commented 8 years ago

Hey there, sorry it's taken so long to get back to you – thanks again for the PR, I'm going to review and make changes this weekend 🙇

AndrewBennet commented 8 years ago

No worries - it's not a big deal :) Cheers!