Dilip Tilonia
Dilip Tilonia

Reputation: 63

How to pass Data from one view controller to another in ios

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

Upvotes: 1

Views: 137

Answers (1)

Prajnaranjan Das
Prajnaranjan Das

Reputation: 1428

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

Upvotes: 1

Related Questions