 			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 !previouslyInsertedObjects.isEmpty {
				processUpdatedObjects(previouslyInsertedObjects,
				                      inserted: &insertedIds,
				                      updated: &updatedIds,

			// Search inserted objects in the context.
			let inMemoryResults = context.insertedObjects
				.flatMap { object -> E? in
					return qualifyingObject(object)
				}

			prefetcher?.reset()
