1

i'm trying to pass data from one view controller to another, here i'm using the button to perform segue

 @IBAction func entered(_ sender: UIButton) {
    performSegue(withIdentifier: "segue1", sender: self)
}

and i've checked the identifier also correct spelled and when i click on entered button then is error come up

2018-06-21 09:08:26.859232+0530 passData2[2886:91217] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '-[UITableViewController loadView] instantiated view controller with identifier "UIViewController-2KP-T7-TXr" from storyboard "Main", but didn't get a UITableView.'

anyone has idea why this is coming up

Dilip Tilonia
  • 63
  • 1
  • 6
  • I think the problem is not in your code, it should be in your "Main" storyboard, can you post settings of viewcontroller which is loaded from "segue1" – Ti3t Jun 21 '18 at 04:00
  • the log seems segue identifier in code and Main.storyboard are not the same and lead to confict. – Tung Vu Duc Jun 21 '18 at 04:05
  • Possible duplicate of [Passing Data between View Controllers](https://stackoverflow.com/questions/5210535/passing-data-between-view-controllers) – Jigar Jun 21 '18 at 04:37
  • The title of the question is misleading. Also please mention which line of code the app crashes on. You have given very little info. Please show more code and which line the app crashes on and relevant code in both view controllers. – Skywalker Jun 21 '18 at 06:27

1 Answers1

1

1st check these things...

  • Make sure the name is correct you entered . Steps i will follow

  • Add a UIViewController/UITableviewcontroller

  • Embed it with navigation controller

  • Add a tableview(connect datasource and delegate and outlet it exist)

  • add a storyboardId

  • Copy-Paste that name and add it to the code where push is implemented

  • Delete the app from simulator build and run again.

Then Try This...

Change your super class to UIViewController or change the controller in your storyboard to TableViewController

@interface MTViewController : UIViewController, UITableViewDataSource, UITableViewDelegate

@end

For Your reference...

Pass Data Between View Controllers In Swift can be done in different ways like:

1   By using an instance property (A → B)
2   By using segues (for Storyboards)
3   By using instance properties and functions (A ← B)
4   By using the Delegation pattern
5   By using a closure or completion handler
6   By using NotificationCenter and the Observer pattern

Try to read this link

Prajnaranjan Das
  • 1,378
  • 1
  • 9
  • 26