I have enum named PinpadModelCallback, declared like this:
enum PinpadModelCallback {
case Connecting
case SelectDevice
case DevicesUpdated
case Configuring
case Stopping
case Stopped
case CardWaiting
case TerminalProcessing
case TransactionStarted
case SignatureRequest
case ApplicationSelection
case TransactionSuccess(result: LTransactionResult)
case TransactionError(msg: String)
case AuthError(msg: String)
}
I have function in which i pass enum type as an argument and try to check it:
private func setInstuction(_ msg: String, callback: PinpadModel.PinpadModelCallback? = nil) {
guard let callback = callback else { return }
if callback == .Connecting {
}
The following code produce an error:
Binary operator '==' cannot be applied to operands of type 'PinpadModel.PinpadModelCallback' and '_'
It work with switch case:
switch callback {
case .Connecting:
break
default:
break
}
But i want to use if else
. Why it's produce an error?