ios - 在 prepareForSegue :sender 中传递数据时,iPhone 应用程序崩溃

标签 ios iphone segue

我一直在尝试将数据从一个 tableViewController 传递到另一个 tableViewController,但是一旦我为第二个 tableViewController 中的属性赋值,应用程序就会崩溃,给我消息“...无法识别的选择器已发送到实例 0x715c340 ……”。 这是我使用的代码:

-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender{
    if([segue.identifier isEqualToString:@"displayWordlist"]){
        DisplayWordlist *dwl = (DisplayWordlist *)[segue destinationViewController];
        dwl.apa = @"hej";
    }
}

一旦程序到达 'dwl.apa = @"hej";'它崩溃了。我既做了apa的一个属性,又合成了。

最佳答案

确保您已将此 View Controller 的类设置为 Storyboard 中的 DisplayWordlist。如果不这样做,dwl 将被假定为 UIViewController 的一个实例,尽管进行了强制转换。

关于ios - 在 prepareForSegue :sender 中传递数据时,iPhone 应用程序崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15342767/

相关文章:

ios - SKTexture : Error loading image resource

iphone - iOS 应用程序如何以重复的方式(即每小时一次)在后台运行某个函数?

iphone - 使用 Storyboard在两个 Controller 之间传递数据

iOS 不止一个 Unwind Segues on a Button

swift - 有没有办法在快速 ViewController 中执行条件转场?

ios - 按索引移动数组中的元素

ios - 如何更改 Apple Watch 的 WKInterfaceImage 对象的框架或大小?

ios - NSPredicate 对对象数组中的对象应用谓词。

iphone - 为什么设置图层边界矩形的anchorPoint 行为如此奇怪?

ios - 蓝牙连接至 iPhone 的设备