mergesort mergesort - 1 year ago 129
iOS Question

How to compare Obj C enum in Swift?

I am using FreeStreamer in Swift and am trying to set the


audioStream.onStateChange = { (state) in
if state == kFsAudioStreamBuffering {

I am getting this error:

Binary operator '==' cannot be applied to operands of type '(FSAudioStreamState)' and 'FSAudioStreamState'

Edit: Still the same error without the parentheses around state in the block params

EDIT: As a temporary fix,
state.value == kFsAudioStreamBuffering.value

Answer Source

try putting a dot (.) before kFsAudioStreamBuffering something like this:

if state == .kFsAudioStreamBuffering {

UPDATE: Try this instead

audioStream.onStateChange = { state in
    if state.value == kFsAudioStreamBuffering.value {
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download