Tolgay Toklar Tolgay Toklar - 10 months ago 103
Swift Question

Binary operators with Swift 3

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

if cma.socket.status != .Connected {

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?

Answer Source

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 {