Не могу отправить ячейку массива при нажатии

swift
xcode
ios

#1

При нажатии на ячейку отправляется весь массив,а не отдельный элемент

import UIKit

class ViewController: UIViewController, UITableViewDataSource, UITableViewDelegate {

var labels = ["bla1", "bla2", "bla3", "bla4", "bla4"]


public func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
    
    
    return labels.count
}

public func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
    let cell = tableView.dequeueReusableCell(withIdentifier: "CustomCell", for: indexPath) as! CustomCell
    
    cell.TextLabel.text = labels[indexPath.row]
    return cell
}

func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
    return 150
}


@IBOutlet weak var TableView: UITableView!


@IBAction func ButtonPressed(_ sender: UIButton) {
    
    let activityVC = UIActivityViewController(activityItems: labels, applicationActivities: nil)
    activityVC.popoverPresentationController?.sourceView = self.view
    
    self.present(activityVC, animated: true, completion: nil)
}



override func viewDidLoad() {
    super.viewDidLoad()
    
    TableView.delegate = self
    TableView.dataSource = self
    // Do any additional setup after loading the view.
}

override func didReceiveMemoryWarning() {
    super.didReceiveMemoryWarning()
    // Dispose of any resources that can be recreated.
}


/*
// MARK: - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
    // Get the new view controller using segue.destinationViewController.
    // Pass the selected object to the new view controller.
}
*/

}

#2

Не буду прямо отвечать, давайте помогу вам самим понять.
Как вы думаете, в каком месте из того кола что вы скинули вы передаете данные?


#3

Тут я отправляю данные ,когда нажимаю на кнопку (кнопка поделиться)

@IBAction func ButtonPressed(_ sender: UIButton) {

let activityVC = UIActivityViewController(activityItems: labels, applicationActivities: nil)
activityVC.popoverPresentationController?.sourceView = self.view

self.present(activityVC, animated: true, completion: nil)
}

#4

в этой вывожу данные

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

cell.TextLabel.text = labels[indexPath.row]
return cell
}

#5

Хорошо, теперь углубляемся:
В какой строчке вы передаете данные?


#6

activityItems: labels, applicationActivities: nil

В этой я передаю массив labels


#7

Хорошо, вы передаете массив!а что вам нужно?конкретный елемент?


#8

Да , конкретный элемент массива. Допустим. При нажатии на bla - передаю только сообщение с текстом “bla” , а передается все.