mardi 29 août 2023

randomize contents of tableview cells

I what I have below is the code that loads string from core data named title. What I would like to do is have a func that randomizes the order of the way all the names are displayed on the tableview cell every time the button is pressed. If possible also save the new order.

func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        let song = songs[indexPath.row]
        let cell = tableView.dequeueReusableCell(withIdentifier: "songCell", for: indexPath) as UITableViewCell
        cell.textLabel?.text = song.title
        return cell
    }



Aucun commentaire:

Enregistrer un commentaire