When stored data retrieving from coredata to tableview, the text dispalying in one cell itself, its not displaying another cell

31 views Asked by At

When stored data retrieving from CoreData to tableView, the text displaying in one cell itself, its not displaying another cell. how can I get the text in individual cells.

    func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        return tasks.count
    }
    func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        let cell = UITableViewCell()
        let task = tasks[indexPath.row]
        cell.textLabel?.text = task.name
        return cell
    }
    func getData()
    {
      let context =  (UIApplication.shared.delegate as! AppDelegate).persistentContainer.viewContext
        do{
        tasks = try context.fetch(Task.fetchRequest())
        }catch{
            print("fetching error")
        }
    }
    override func viewWillAppear(_ animated: Bool) {
        getData()

        tableView.reloadData()
    }

simulator

0

There are 0 answers