In my swift code what I would like to do is segue a name from a table view cell to a new class. I do not want to do the the navigation bar with the built in library from any of this operation. The code should segue the text on the table view when the user touches the table view cell to class two in display on label lbl. Everything should be done in storyboard.
class ViewController: UIViewController, UITableViewDelegate, UITableViewDataSource {
var itemName: [NSManagedObject] = []
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return itemName.count
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let title = itemName[indexPath.row]
let cell = theTable.dequeueReusableCell(withIdentifier: "MyCell", for: indexPath)
cell.textLabel!.numberOfLines = 2
cell.selectionStyle = .default
let attr1 = title.value(forKey: "name") as? String
let text = [" : ", attr1].flatMap { $0 }.reduce("", +)
cell.textLabel?.text = "Item \(indexPath.row + 1) \(text)"
cell.textLabel?.textAlignment = .center
cell.layoutMargins = UIEdgeInsets.zero
cell.preservesSuperviewLayoutMargins = false
cell.separatorInset = UIEdgeInsets.zero
cell.layoutMargins = UIEdgeInsets.zero
return cell
}
}
class Two: UIViewController {
var lbl = UILabel()
override func viewDidLoad() {
super.viewDidLoad()
}
}