Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Swift 'use of undeclared type'

Tags:

ios

swift

I'm currently trying to write a little iOS application in swift, where I have these Classes: masterTableViewController addViewController and deleteViewController, each of them is connected to a, like the name already tells, viewController. The masterTableViewController should sent some data using the predefined function:

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

  if(segue.identifier == "showDetails") {
    var selectedIndexPath:NSIndexPath = self.tableView.indexPathForSelectedRow()!

    var deleteViewController:deleteViewController = segue!.destinationViewController as deleteViewController

    deleteViewController.todoData = todoItems.objectAtIndex(selectedIndexPath.row) as NSDictionary
}

I want to send the data of the current row to the next, by segue referenced controller.

This is where I get an error message stating that deleteViewController is not a type that can be assigned to a variable.

But I don't really understand what the problem s right now. Basically this should work because I just want to create a new object of the type my class is of and pass this one to my view controller.

In the reference I got this code from everything worked just fine.

like image 977
hGen Avatar asked Dec 25 '22 04:12

hGen


1 Answers

You are mixing class names and instance variable names. Class names should be upper case: MasterTableViewController, AddViewController, DeleteViewController

At first, try to distinguish between the class name and the instance variable name by choosing a different name, i.e.:

var dvc:deleteViewController = segue!.destinationViewController as deleteViewController
dvc.todoData = ...

And see if it works

like image 131
zisoft Avatar answered Jan 13 '23 02:01

zisoft