create the button array for store the current state of your check box button and connect your checkboxbutton this array, it will be used for get the current state of your button
var getSelectedState: [UIButton] = []
get your checkbox button current state using first(where:)
Returns the first element of the sequence that satisfies the given predicate.
var handleButtonState : Bool{
var setState = false
if let getNotSelectedState = getSelectedState.first(where: { $0.isSelected == false }) {
print("get the non selectedState of button \(getNotSelectedState)")
setState = true
}
return setState
}
finally you can use UItextfield delegate for enable/disable the return key using enablesReturnKeyAutomatically
A Boolean value indicating whether the Return key is automatically enabled when the user is entering text.
// MARK: - Textfield delegates
func textField(_ textField: UITextField, shouldChangeCharactersIn range: NSRange, replacementString string: String) -> Bool {
guard let currentText = (textField.text as NSString?)?.replacingCharacters(in: range, with: string) else { return true }
textField.enablesReturnKeyAutomatically = !currentText.isEmpty && !handleButtonState ? true : false
return true
}