lundi 22 mai 2017

How to display saved checklist in tableview swift ios

i want make table view display saved data . i tried but failed I want keep the checklist after the save and I reopen the view

please help me for solved my problem

this my code

var id = [17,18,19]

func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        let cellTheme: ThemeCell = self.tableView.dequeueReusableCell(withIdentifier: "cellTheme", for: indexPath) as! ThemeCell

        cellTheme.themeLabel.text = listMenu[indexPath.row].theme
        cellTheme.delegate = self

        if id.isEmpty{

            cellTheme.checkOutlet.image = UIImage(named: "ic_btn_home_checklist_off")

            print("EMPTY")

        }else{

            for data in id{

                print("TEST THEME \(id)")

                print("DATA ! \(data)")

                if listMenu[indexPath.row].id == data{

                    print("\(listMenu[indexPath.row].id) SAMA DENGAN DATA ")
                    cellTheme.checkOutlet.image = UIImage(named: "ic_btn_home_checklist_on")

                }else{

                    print("\(listMenu[indexPath.row].id) TIDAK SAMA DENGAN DATA ")
                    cellTheme.checkOutlet.image = UIImage(named: "ic_btn_home_checklist_off")

                }

            }

        }

        return cellTheme

    }

Note : listMenu[indexPath.row].id = [17,18,19,146]




Aucun commentaire:

Enregistrer un commentaire