Check data exist before saving in coredata -Swift
While saving the data am checking whether the data is already exist or not in the entity. Problem here is the above method is not working as expected, when I run the app for very first time it's showing data is already exist. Please check the below code and shed some light. Thanks. func someEntityExists(id: String, entityName: String, type : String, fieldName : String) -> Bool { let fetchRequest = NSFetchRequest<NSManagedObject>(entityName: entityName) if type == "String"{ fetchRequest.predicate = NSPredicate(format: "\(fieldName) == %@", id) }else{ fetchRequest.predicate = NSPredicate(format: