Hi I am not good at Swift and am getting a signal error. I couldn't find anything that can cause it. I really want to finish this app, can someone help me please.
error-video https://www.dropbox.com/s/xlvo22fvurivize/error.mov?dl=0
Since I just use option-drag for the segue I am not sure it is related with the code. Should I add something in that class, maybe there is something that I missed ?
Could not cast value of type 'recipeApplication.ViewController' (0x1041ff030) to 'recipeApplication.matchesPageViewController' (0x1041ff0d0).
This is the error.
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
let matchesPage: matchesPageViewController = segue.destinationViewController as! matchesPageViewController
for var i = 0, a = 0 ; i < data(0).2 ; i++ {
if data(i).0.isSubsetOf(choosenSet) == true {
self.myMatchedArray.insert(self.data(i).1, atIndex: a)
a++
}
}
for var i = 0 ; i < myMatchedArray.count ; i++ {
//print(myMatchedArray[i])
matchesPage.dataArray.append(myMatchedArray[i])
}
}
This is the code in my prepareforsegue but like in the video, I have used this one for going another viewController so I did not use it for going back. Like I said I just declared it with a segue ...
Any idea is appreciated. Thanks
答案 0 :(得分:0)
正如评论中所述,在打印segue.destination
时,您收到了<recipeApplication.ViewController: 0x7f9f1a42b670>
。这意味着你的segue的目的地是ViewController
。但是,您尝试将ViewController
转换为matchesPageViewController
。这就是你收到错误的原因。你应该检查一下。
if let matchesPage = segue.destinationViewController as? matchesPageViewController {
//Do code
}
希望这有帮助。