I am using swift 2 beaucse my lappy does not suppoeted swift 3 beacuse of some issue.
I want to pass data from view controller to table view controller ..
but i got some error and here is my code
I want to pass value form view controller .I am using label . whatever i will write in label it will disply in table view controller. so it will REALTIME value !
I am using two view controller and one table view controller ...i have error in table view controller. I have some errors
1) cell1.textLabel!.text = tblLable.text! // error UItableview has no memeber in 'text'
view controller
@IBOutlet var labelText: UITextField!
override func viewDidLoad()
{
super.viewDidLoad()
}
override func didReceiveMemoryWarning()
{
super.didReceiveMemoryWarning()
}
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?)
{
let DestViewController:PassDataView = segue.destinationViewController as! PassDataView
DestViewController.passdata = labelText.text!
//print(DestViewController.passdata)
}
passdataview
@IBOutlet var Label: UILabel!
var passdata=String()
override func viewDidLoad()
{
Label.text=passdata
}
}
tableviewcontroller
override func viewDidLoad() {
super.viewDidLoad()
//myTableView.delegate = self;
// myTableView.dataSource = self;
}
@IBOutlet var tblLable: UITableView!
override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return 10
}
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?)
{
let DestViewController:PassDataView = segue.destinationViewController as! PassDataView
DestViewController.passdata = tblLable.text!// error UItableview has no memeber in 'text'
}
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell
{
let cell1 = tableView.dequeueReusableCellWithIdentifier("cell1", forIndexPath: indexPath)
cell1.textLabel!.text = tblLable.text! // error UItableview has no memeber in 'text'
return cell1
}
UITableViewhas no variabletext, that's why you're seeing the error