Binary operators with Swift 3

Tolgay Toklar

I am switching to Swift 3 and i am getting following compiler error for this line:

    if cma.socket.status != .Connected {
        cma.socket.connect()
        print("connect");
    }else{
        cma.socket.reconnect()
        print("reconnect")
    }

Binary operator '!=' cannot be applied to operands of type 'SocketIOClientStatus' and '_'

I found this question: Swift 3.0 binary operator '==' cannot be applied but still don't know how to fix it.

How can I resolve this problem?

rmaddy

The enum is defined as:

@objc public enum SocketIOClientStatus : Int {
    case notConnected, disconnected, connecting, connected
}

This means your code needs a small change (pun intended):

if cm.socket.status != .connected {

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related