ios - Parse Swift UITableView Accessory -


i have following code, , trying implement accessory uitableview. data parse, though there tutorials out there helping out on how normal accessory, unable find 1 teaches on how if getting data online db parse.

// //  listdoctors.swift //  ihealthtwo // //  created david on 10/1/16. //  copyright © 2016 ƒ. rights reserved. //  import uikit import parse  class listdoctors: uitableviewcontroller {      @iboutlet var listdoctors: uitableview!       var doctorname = [string]()     var doctorrate = [nsinteger]()     var doctordetail = [string]()       var refresher: uirefreshcontrol!         func refresh()     {        let query = pfquery(classname: "doctors")         query.orderbydescending("createdat")          query.findobjectsinbackgroundwithblock(              {                 (listll: [pfobject]?, error: nserror?) -> void in                  if error == nil {                     // find succeeded.                     print("successfully retrieved \(listll!.count) names of lawyers.")                     // found objects                     if let objects = listll {                         object in objects {                             print(object)                              self.doctorname.append(object["doctorname"] as! string)                             self.doctorrate.append(object["rate"] as! nsinteger)                             self.doctordetail.append(object["doctorcontent"] as! string)                               // print(object["lawyer_name"] as! string )                             // self.lawyersname.append(object["lawyer_name"] as! string)                             //self.lblname.text = object["lawyer_name"] as? string                          }                         self.listdoctors.reloaddata()                     }                     print(self.doctorname.count)                 } else {                     // log details of failure                     print("error: \(error!) \(error!.userinfo)")                 }                 self.tableview.reloaddata()                 self.refresher.endrefreshing()         })      }       override func viewdidload() {         super.viewdidload()          refresher = uirefreshcontrol()         refresher.attributedtitle = nsattributedstring(string: "pull refrehsh")         refresher.addtarget(self, action: "refresh", forcontrolevents: uicontrolevents.valuechanged)         self.tableview.addsubview(refresher)          refresh()           // uncomment following line preserve selection between presentations         // self.clearsselectiononviewwillappear = false          // uncomment following line display edit button in navigation bar view controller.         // self.navigationitem.rightbarbuttonitem = self.editbuttonitem()     }      override func didreceivememorywarning() {         super.didreceivememorywarning()         // dispose of resources can recreated.     }      // mark: - table view data source      override func numberofsectionsintableview(tableview: uitableview) -> int {         // #warning incomplete implementation, return number of sections         return 1     }      override func tableview(tableview: uitableview, numberofrowsinsection section: int) -> int {         // #warning incomplete implementation, return number of rows         return doctorname.count     }       override func tableview(tableview: uitableview, cellforrowatindexpath indexpath: nsindexpath) -> uitableviewcell {         let doctorcell: doctorscell = tableview.dequeuereusablecellwithidentifier("doctorsproto") as! doctorscell          // configure cell...         doctorcell.doctorname.text = doctorname[indexpath.row]         doctorcell.doctorcontent.text = doctordetail[indexpath.row]          doctorcell.doctorrate.text = "\(doctorrate [indexpath.row])"          //lawyercell.lblexpll.text = lawyerexp[indexpath.row]         //lawyercell.lblpracareall.text = lawyerpracarea[indexpath.row]         //profimages[indexpath.row].getdatainbackgroundwithblock{(imagedata: nsdata?, error: nserror?) -> void in           //  if imagedata != nil {            //     let image = uiimage(data: imagedata!)             //    lawyercell.imagelawyer.image = image            // }            // else            // {             //    print(error)            // } }          return doctorcell     }      override func tableview(tableview: uitableview, didselectrowatindexpath indexpath: nsindexpath)     {         print(indexpath.row)     }       // mark: - navigation doctor detail      override func prepareforsegue(segue: uistoryboardsegue, sender: anyobject?) {         if let identifier = segue.identifier         {             switch identifier             {                 doctor "todoctordetail":                     let productdetailvc = segue.destinationviewcontroller as! doctordetail                 if let indexpath = self.tableview.indexpathforcell(sender as! uitableviewcell)                 {                  }               default: break             }         }ˍ     }         //mark: - helper method       //func productatindexpath(indexpath: nsindexpath) ->?? (waht should put here)    } 

my last line of code not sure need return, example following https://www.youtube.com/watch?v=c-e_ebmr9wa

from looks of it, you're trying pass data detail view in case should doing assuming have proper indexpath , variables defined in detailview already.

  override func prepareforsegue(segue: uistoryboardsegue, sender: anyobject?) {             if let identifier = segue.identifier             {                 switch identifier                 {                     doctor "todoctordetail":                         let productdetailvc = segue.destinationviewcontroller as! doctordetail                     if let indexpath = self.tableview.indexpathforcell(sender as! uitableviewcell)                     {                        // assuming have proper indexpath defined here selected cell , have these 3 values defined in productdetailvc                       productdetailvc.doctorname = doctorname[indexpath.row]                       productdetailvc.doctorcontent = doctorcontent[indexpath.row]                       productdetailvc.doctorrate = doctorrating[indexpath.row]                     }                   default: break                 }             }ˍ         } 

Comments

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

post - imageshack API cURL -

dataset - MPAndroidchart returning no chart Data available -