Reputation: 2285
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.
Upvotes: 4
Views: 13295
Reputation: 8819
This can occur if the class you are compiling is included in a unit test module, but the class that is not defined is not.
You will find that the app compiles and runs, but compilation errors may be shown in the source.
Open the right bar and check the Target Membership settings. They should be consistent for both classes.
Upvotes: 1
Reputation: 4444
I realize you already have an accepted answer, but I've been chasing this error for too long and finally found the cause of my issue so maybe it'll help someone keep their sanity.
I encountered this issue when trying to integrate the Google admob sdk.
Here are the steps I took to debug:
So apparently Xcode doesn't like hyphens in framework search paths.
Upvotes: 0
Reputation: 2016
Another scenario where you might get mysterious 'use of undeclared type': the type (here DeleteViewController class) is defined in a file that you renamed by changing the 'Name' text box of the 'Utilities' pane. Then Xcode MIGHT not think the file is a member of the target, even though the checkboxes in the 'Target Membership' section of the 'Utilities' pane shows that the file IS a member of the project target. The workaround is to uncheck and recheck the checkbox that makes the file a member of the target. Xcode will reindex the project files and hopefully now consider the file a member of the target.
Upvotes: 2
Reputation: 23078
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
Upvotes: 7