0

私が取り組んでいるプロジェクトでは (Object-C ではなく Swift を使用しています!!!)、BLE 特性から抽出した UInt16 を文字列に変換する必要があるため、ラベルのテキストとして使用できます。すでにこの問題を解決した人はいますか?

事前にご協力いただきありがとうございます。

var currentValue: UInt16!

func peripheral(peripheral: CBPeripheral!, didUpdateValueForCharacteristic characteristic: CBCharacteristic!, error: NSError!) {
   if characteristic.UUID == xgatt_io_p_1 {
      let data = characteristic.value
      let reportData = UnsafePointer<UInt16>(data.bytes)
      currentValue = reportData.memory
   }
   readValue()
}

label.text = convertedCurrentValue
4

1 に答える 1

0

あなたはこれを行うことができます:

label.text = "\(convertedCurrentValue)"
于 2015-01-23T15:06:47.773 に答える