Oleksandr Matrosov
Oleksandr Matrosov

Reputation: 27133

Swift if sentences issue

I am new in Swift and usually work with objective-c and as obj c user it's simple form me to use sentence if (something) then.... but with a Swift it's a little bit complicated. What I did wrong.

let isConnected = QBChat.instance().isConnected

if isConnected // issue Type '() -> Bool' does not conform to protocol 'BooleanType'
{

}

Upvotes: 0

Views: 55

Answers (2)

Rob
Rob

Reputation: 437582

It would appear that isConnected is not a property, but rather a function or closure. I think you might mean

let isConnected = QBChat.instance().isConnected()

It's hard to know for sure without seeing how isConnected was defined. If the above doesn't work, please show us its definition.

Upvotes: 1

hris.to
hris.to

Reputation: 6363

Looks like isConnected is closure. Try following

QBChat.instance().isConnected { isConnected in
    //do stuff
}

Upvotes: 0

Related Questions