0

Then i try to sent data from one view to another

override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {

    if segue.identifier == "varView" {
        var viewController = segue.destinationViewController as ViewController

        var indexPath = self.tableView.indexPathForSelectedRow()

        viewController.varView = self.exams[indexPath.row]

    }

}

I get an error at witch says that ViewController is a undeclared?

BenjaBob
  • 29
  • 7

1 Answers1

0

Rather than prepareForSegue you can directly call viewController from storyboard and pass the data

declare variable in the file you want to pass the data and #import the header file in which you want to pass the data.

#import "file.h"

file *data = [[file alloc]init];
data.index = add_index;

then navigate as follow...

UINavigationController *navigationController = (UINavigationController *)self.navigationController;
UIViewController *createEvent = [self.storyboard instantiateViewControllerWithIdentifier:@"yourViewControllerID"];

[navigationController pushViewController:createEvent animated:YES];
Dharmesh Kheni
  • 71,228
  • 33
  • 160
  • 165
objectiveCoder
  • 579
  • 5
  • 17