ios - Transferring UITableView Section to Another TableView -


i set transfer section 1 of tableview tableview. done moving didselectrow: rows. however, issue when attempt move section when every row selected (and there nothing in section 0) crashes index beyond bounds error.

i using boilerplate code sectionheaders due section 1 header changing section 0 header when items selected in section 1. believe causing index out of bounds error, not sure how correct it.

my sections set as:

func numberofsectionsintableview(tableview: uitableview) -> int {     let numberofsections = frc.sections?.count     return numberofsections! }  //table section headers func tableview(tableview: uitableview, titleforheaderinsection section: int) -> string?{     let sectionheader = "items needed - #\(frc.sections![section].numberofobjects)"     let sectionheader1 = "items in cart - #\(frc.sections![section].numberofobjects)"     if (frc.sections!.count > 0) {         let sectioninfo = frc.sections![section]         if (sectioninfo.name == "0") {              return sectionheader         } else {             return sectionheader1         }     } else {         return nil     } } 

with didselectrow , cells as:

func tableview(tableview: uitableview, cellforrowatindexpath indexpath: nsindexpath) -> uitableviewcell {      let cell = tableview.dequeuereusablecellwithidentifier("cell", forindexpath: indexpath) as! sltableviewcell      //assign delegate     cell.delegate = self      let items = frc.objectatindexpath(indexpath) as! list     cell.backgroundcolor = uicolor.clearcolor()     cell.tintcolor = uicolor.graycolor()     cell.celllabel.text = "\(items.slitem!) - qty: \(items.slqty!)"     cell.celllabel.font = uifont.systemfontofsize(25)     movetopl.hidden = true      if (items.slcross == true) {         cell.accessorytype = .checkmark         cell.celllabel.textcolor = uicolor.graycolor()         cell.celllabel.font = uifont.systemfontofsize(20)         self.tableview.rowheight = 50         movetopl.hidden = false      } else {         cell.accessorytype = .none         cell.celllabel.textcolor = uicolor.blackcolor()         cell.celllabel.font = uifont.systemfontofsize(25)         self.tableview.rowheight = 60         movetopl.hidden = true     }     return cell }  func tableview(tableview: uitableview, didselectrowatindexpath indexpath: nsindexpath) {      let items = frc.objectatindexpath(indexpath) as! list      if (items.slcross == true) {         items.slcross = false     } else {         items.slcross = true     }     tableview.reloaddata() } 

is issue or else causing this?

edit: tried changing function in charge of moving items this:

@ibaction func movetopantry(sender: anyobject) {      let sectioninfo = self.frc.sections![1]     let objectstoappend = sectioninfo.objects as! [list]     item in objectstoappend {         item.slist = true         item.slcross = false         item.plist = false         item.slitem = item.pitem         item.slqty = item.pqty         item.sldesc = item.pdesc         item.slprice = item.pprice         item.slminqty = item.pminstepperlabel      } } 

to:

@ibaction func movetosl(sender: anyobject) {     if (frc.sections!.count > 0) {     let sectioninfo = self.frc.sections![1]           if (sectioninfo.name == "0") {     let objectstoappend = sectioninfo.objects as! [list]     item in objectstoappend {         item.slist = true         item.slcross = false         item.plist = false         item.slitem = item.pitem         item.slqty = item.pqty         item.sldesc = item.pdesc         item.slprice = item.pprice         item.slminqty = item.pminstepperlabel             }         }     } } 

it still throwing error. move objects long section 0 isn't empty. more in figuring out appreciated! in advance.


Comments

Popular posts from this blog

Hatching array of circles in AutoCAD using c# -

ios - UITEXTFIELD InputView Uipicker not working in swift -

Python Pig Latin Translator -