0

in this i am assigning some value to url variable, but this variable is not getting any value. i used the breakpoint to check the value it shows nil value. i used the print statement for testing the variable abc is getting perfect value but it is not assigning to url variable. the same code i used in the other view controller and these are working perfectly. i don't know what's the problem with this code. Please help me out.

        let currentCell = tableView.cellForRow(at: indexPath!)!
        print(currentCell.textLabel!.text!)
        let abc = currentCell.textLabel!.text!
        print (indexPath!)
        print(abc)

        let url = URL(string: self.con+"deletelocation?email=hassan.shahid94@yahoo.com&name=\(abc)")
        let task = URLSession.shared.dataTask(with: url!) {(data, response, error) in
            DispatchQueue.main.async(execute: { () -> Void in
                if error != nil
                {
                    print("Error")
                }

                else
                {
                    if let content = data
                    {
                        do
                        {
                            let myJson = try JSONSerialization.jsonObject(with: content, options: JSONSerialization.ReadingOptions.mutableContainers) as! NSDictionary
                            let asd = myJson.value(forKey: "deletelocationResult")
                            print(asd!)
                            self.get()
                            self.tableview.reloadData()
                            self.tableview.deleteRows(at: [indexPath!], with: .fade)
                        }

                        catch
                        {

                        }



                    }



                }

            })
        }
        task.resume()

0 Answers0