如何比较Swift中的Obj C enum?

时间:2015-08-14 14:42:47

标签: ios swift

我在Swift中使用FreeStreamer并尝试设置google.maps.event.addListener(marker, 'click', (function(marker, i) { return function() { infowindow.setContent(locations[i][0]); infowindow.open(map, marker); } })(marker, i)); 块。

onStateChange

我收到此错误:

audioStream.onStateChange = { (state) in
    if state == kFsAudioStreamBuffering {
        //blah
    }
}

编辑:在块参数中没有括号的括号

时仍然是相同的错误

编辑:作为临时修复,Binary operator '==' cannot be applied to operands of type '(FSAudioStreamState)' and 'FSAudioStreamState' 正常工作

2 个答案:

答案 0 :(得分:1)

尝试在kFsAudioStreamBuffering之前加一个点(。) 像这样的东西:

if state == .kFsAudioStreamBuffering {
    //blah
}

更新:改为尝试

audioStream.onStateChange = { state in
    if state.value == kFsAudioStreamBuffering.value {
        //blah
    }
}

答案 1 :(得分:0)

它应该是这样的,使它工作。

    self.audioControler?.onStateChange = { (state:FSAudioStreamState) -> Void in
        switch state {
        case .fsAudioStreamRetrievingURL: