Vai al contenuto

aggiornamenti storyboard simulatore


Messaggi raccomandati

Salve a tutti, da premettere che sono alle prime armi con SWIFT, dopo tanto tempo per riuscire a capire come riuscire a collegare il mio database mysql in remote... tramite JSON ho un'altro problema che mi sta facendo impazzire :

 

una volta che i dati sono ricevuti passano almeno 3-4 secondi per aggiornamento dei vari oggetti sulla storyboard, dove sbaglio? oppure e normale a causa del simulatore? lo script :

 

//creating a task to send the post request

        let task = URLSession.shared.dataTask(with: request as URLRequest){

            data, response, error in

            

            if error != nil{

                print("error is \(error ?? 100 as! Error)")

                return;

            }

            

            //parsing the response

            do {

                //converting resonse to NSDictionary

                let myJSON =  try! JSONSerialization.jsonObject(with: data!, options: .mutableContainers) as? NSDictionary

                

                //parsing the json

                if let parseJSON = myJSON {

                    

                    //creating a string

 

                    

                    //getting the json response

                    var msg : String!

                    msg = parseJSON["message"] as! String?

                    self.txnome.text = parseJSON["nome"] as! String?

                    self.txmember.text = parseJSON["member"] as! String?

                    self.txid.text = parseJSON["id"] as! String?

                    print(msg)

                }

            }

            

        }

        task.resume()

 

grazie mille 

Link al commento
Condividi su altri siti

Archiviato

Questa discussione è archiviata e chiusa a future risposte.

×
×
  • Crea Nuovo...