错误消息:成员'withUnsafeBytes'的引用不明确

时间:2019-08-10 13:38:44

标签: swift

我对如何解决此代码感到困惑。

我正在将数据从swift应用程序发送到在树莓派上运行的python套接字服务器,并且不断收到此错误消息。我正在使用本教程:http://studyswift.blogspot.com/2016/03/sending-rsa-encrypted-message-from-ios_3.html

  //network vars
    var inStream : InputStream?
    var outStream: OutputStream?

    //recieved data
    //var buffer = [UInt8](count: 2000, repeatedValue: 0)
    var inStreamLength: Int!
    var keyString = ""

    func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) {
        guard let locValue: CLLocationCoordinate2D = manager.location?.coordinate else { return }

        label1.text = String(format:"%f", locValue.latitude)
        label2.text = String(format:"%f", locValue.longitude)

        func getKey() {
            let data: Data = "Client: OK".data(using: String.Encoding.utf8)!
            outStream?.write(UnsafePointer<UInt8>(data.withUnsafeBytes), maxLength: data.length)   
        }

我在outStream上收到错误消息?.write(...) “对成员'withUnsafeBytes'的歧义引用”

0 个答案:

没有答案