Type of expression is ambiguous without more conte

2019-07-08 09:51发布

i am implementing pod 'Socket.IO-Client-Swift'

but in SocketEngine.swift file i'm getting this error.

 private func handleBase64(message: String) {
            // binary in base64 string
            let noPrefix = message[message.index(message.startIndex, offsetBy: 2)..<message.endIndex]

            if let data = Data(base64Encoded: noPrefix, options: .ignoreUnknownCharacters) {
                client?.parseEngineBinaryData(data)
            }
        }

enter image description here

thanks in advance!!

标签: ios swift swift4
1条回答
别忘想泡老子
2楼-- · 2019-07-08 10:17

noPrefix is of type Substring, just coerce it to String:

if let data: Data = Data(base64Encoded: String(noPrefix), options: .ignoreUnknownCharacters) {
    ...
}
查看更多
登录 后发表回答