fix iOS 10 NSFetchedResultsController bug for iOS 7-supporting branch

This commit is contained in:
John Estropia
2016-11-08 10:04:49 +09:00
parent 0dbd05b172
commit 81c5b0c650
3 changed files with 13 additions and 3 deletions

View File

@@ -108,7 +108,7 @@ internal final class FetchedResultsControllerDelegate: NSObject, NSFetchedResult
return
}
guard let actualType = NSFetchedResultsChangeType(rawValue: type.rawValue) else {
guard var actualType = NSFetchedResultsChangeType(rawValue: type.rawValue) else {
// This fix is for a bug where iOS passes 0 for NSFetchedResultsChangeType, but this is not a valid enum case.
// Swift will then always execute the first case of the switch causing strange behaviour.
@@ -121,6 +121,16 @@ internal final class FetchedResultsControllerDelegate: NSObject, NSFetchedResult
// https://forums.developer.apple.com/message/9998#9998
// https://forums.developer.apple.com/message/31849#31849
if #available(iOS 10.0, tvOS 10.0, watchOS 3.0, *) {
// I don't know if iOS 10 even attempted to fix this mess...
if case .Update = actualType
where indexPath != nil && newIndexPath != nil {
actualType = .Move
}
}
switch actualType {
case .Update: