 			return
 		}
 
-		if let insertedObjects = userInfo[NSInsertedObjectsKey] as? Set<NSManagedObject> {
+		if let insertedObjects = userInfo[NSInsertedObjectsKey] as? NSSet {
 			for object in insertedObjects {
-				guard let object = object as? E else {
+				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.

			}
		}

		if let deletedObjects = userInfo[NSDeletedObjectsKey] as? Set<NSManagedObject> {
			processDeletedObjects(deletedObjects,
			                      deleted: &deletedIndexPaths,
			                      cacheClearing: &cacheClearingIds)
		}

		if let invalidatedObjects = userInfo[NSInvalidatedObjectsKey] as? Set<NSManagedObject> {
			processDeletedObjects(invalidatedObjects,
			                      deleted: &deletedIndexPaths,
			                      cacheClearing: &cacheClearingIds)
		}

		if let updatedObjects = userInfo[NSUpdatedObjectsKey] as? Set<NSManagedObject> {
			processUpdatedObjects(updatedObjects,
			                      inserted: &insertedIds,
			                      updated: &updatedIds,

			                      cacheClearing: &cacheClearingIds)
		}

		if let refreshedObjects = userInfo[NSRefreshedObjectsKey] as? NSSet {
			processUpdatedObjects(refreshedObjects,
			                      inserted: &insertedIds,
			                      updated: &updatedIds,
