Here is code for saving into core data entities:
func save(sensor : Sensor ,date:String,completion: @escaping completionBlock) ->Void
{
let managedContext = (UIApplication.shared.delegate as? AppDelegate)!.persistentContainer.viewContext
let fetchRequest =
NSFetchRequest<NSManagedObject>(entityName: "entity1")
do{
var count = try managedContext.count(for: fetchRequest)
count = count + 1
let entity =
NSEntityDescription.entity(forEntityName: "entity1",
in: managedContext)!
let logs = NSManagedObject(entity: entity,