swift - data lost in segue (xcode8.0) -


i beginner in swift , try develop simple program shows characterisitcs of ble. confirmed print captured uuid of target characteristics

mycharacteristicuuid_1 : (     "manufacturer name string",     "model number string",     "serial number string",     "hardware revision string",     "firmware revision string",     "software revision string" ) 

however, in override func prepare(for segue: uistoryboardsegue, sender: any?), checked again print , see data gone below;

mycharacteristicuuid_2 : ( ) 

i can hand on other types of values (e.g.string, text,etc..) can't handle data captured ble. can point out have when use data ble in segue ? below code;

func peripheral(_ peripheral: cbperipheral, diddiscovercharacteristicsfor targetservice: cbservice, error: error?) {      if error != nil {         print("characteristic not found : \(error)")      }      let foundcharacteristics = targetservice.characteristics      c in foundcharacteristics! [cbcharacteristic] {          mycharacteristicuuid.add(c.uuid)      }      print("mycharacteristicuuid_1 : \(mycharacteristicuuid)")  }  // prepare segue override func prepare(for segue: uistoryboardsegue, sender: any?) {      if (segue.identifier == "mysegue") {          print("mycharacteristicuuid_2 : \(mycharacteristicuuid)")          let mysecondviewcontroller : secondviewcontroller = segue.destination as! secondviewcontroller          mysecondviewcontroller.relayedfoundcharacteristicuuid = mycharacteristicuuid       }  } 

here reason why mycharacterisitcuuid not read correctly. please see place of performsegue.

func tableview(_ tableview: uitableview, didselectrowat indexpath: indexpath) {      selectedservice = myservice[indexpath.row] as! cbservice     print("selected_service : \(selectedservice)")      self.peripheral.discovercharacteristics(nil, for:selectedservice cbservice!)      //performsegue(withidentifier: "mysegue", sender: nil)     // used performed segue here. reason mycharacterisitcuuid empty.   }  // find characteristics targetservice  func peripheral(_ peripheral: cbperipheral, diddiscovercharacteristicsfor targetservice: cbservice, error: error?) {      if error != nil {         print("characteristic not found : \(error)")      }      foundcharacteristics = targetservice.characteristics!      c in foundcharacteristics [cbcharacteristic] {          self.mycharacteristicuuid.add(c.uuid)      }     // segue should performed here ! change worked!     performsegue(withidentifier: "mysegue", sender: nil) } 

Comments

Popular posts from this blog

php - How to add and update images or image url in Volusion using Volusion API -

javascript - jQuery UI Splitter/Resizable for unlimited amount of columns -

javascript - IE9 error '$'is not defined -