我试图在Viewcontrollers之间的xcode 9.4.1上运行一个数组,但在前几行中一直出现sigabrt错误。在进行模拟时,使用数组信息的序列会起作用,但是不依赖数组信息或以任何方式链接到数组信息的序列最终会导致数组代码内出现SIGABRT错误。有人知道怎么了吗?
这是代码;
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
let VC = segue.destination as! ViewController_array
if segue.identifier == "grade1"{
VC.gradeLabel = "Grade 1"
VC.display = "information goes here1"
}
if segue.identifier == "grade2"{
VC.gradeLabel = "Grade 2"
VC.display = "information goes here2"
}
}
(每个年级的最后几行照此继续) 代码的错误在第一行的某处-另一个viewcontroller上的接收器很好,并且没有其他viewcontroller与同一代码相关,这只是这里的第一行之内。 发送者viewcontroller名为“ ViewController”,接收者为“ ViewController_array”
所产生的错误消息是;
objc[11314]: Class VCWeakObjectHolder is implemented in both /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/Library/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/System/Library/PrivateFrameworks/AVConference.framework/Frameworks/ViceroyTrace.framework/ViceroyTrace (0x12d8504d0) and /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/Library/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/System/Library/PrivateFrameworks/AVConference.framework/AVConference (0x12c97ce38). One of the two will be used. Which one is undefined.
Could not cast value of type 'UIViewController' (0x10fee11f0) to 'test2.ViewController_array' (0x10d40a710).
2018-08-18 21:06:07.764832+1000 test2[11314:111648] Could not cast value of type 'UIViewController' (0x10fee11f0) to 'test2.ViewController_array' (0x10d40a710).
(lldb)
答案 0 :(得分:1)
您需要分配班级名称
ViewController_array
到IB内部的VC
答案 1 :(得分:1)
看看错误消息:
Could not cast value of type 'UIViewController' (0x10fee11f0) to 'test2.ViewController_array'
这意味着您要选择使用的视图控制器是类UIViewController
而不是ViewController_array
的实例。 Forced casting UIViewController
到ViewController_array
总是会失败,因为ViewController_array
是UIViewController
的子类,而不是相反。
您必须确保在情节提要的身份检查器中设置正确的视图控制器类: