 		return false
 	}
 
-	private func processDeletedObjects(_ set: Set<NSManagedObject>,
-															 deleted deletedIndexPaths: inout [[Int]],
-															 cacheClearing cacheClearingIds: inout ContiguousArray<NSManagedObjectID>) {
+	private func processDeletedObjects(_ set: NSSet,
+	                                   deleted deletedIndexPaths: inout [[Int]],
+	                                   cacheClearing cacheClearingIds: inout ContiguousArray<NSManagedObjectID>) {
 		for object in set {
-			guard let object = object as? E else {
+			guard type(of: object) is E.Type else {
 				continue
 			}
 
+			let object = object as! E
 			if let cacheIndex = objectCache.index(forKey: object.objectID) {
 				let sectionName: String?
 

		var sortOrderAffectingIndexPaths = sections.indices.map { _ in Set<Int>() }
		var cacheClearingIds = ContiguousArray<NSManagedObjectID>()

		if let _insertedObjects = userInfo[NSInsertedObjectsKey] as? Set<NSManagedObject> {
			var previouslyInsertedObjects = Set<NSManagedObject>()
			for object in _insertedObjects {
				if let object = qualifyingObject(object) {
					if objectCache.index(forKey: object.objectID) != nil {
						previouslyInsertedObjects.insert(object)
					} else {
						let name = sectionName(of: object)
						insertedIds.insert(object.objectID, intoSetOf: SectionKey(name))

			return
		}

		if let insertedObjects = userInfo[NSInsertedObjectsKey] as? NSSet {
			for object in insertedObjects {
				guard type(of: object) is E.Type else {
					continue
				}

				let object = object as! E
				if let temporaryId = temporaryObjects[object] {
					if !object.objectID.isTemporaryID {
						/// If the object ID is no longer temporary, find the position of the object.
