【发布时间】:2014-08-15 09:52:35
【问题描述】:
我的简单类 ClassWithOneArray 产生了这个错误:
Bitcast 要求两个操作数都是指针或两者都不是 %19 = bitcast i64 %18 到 %objc_object*,!dbg !470 LLVM 错误:损坏 找到函数,编译中止!命令 /Applications/Xcode6-Beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift 退出代码 1 失败
但是,我的班级 ClassWithOneInt 没有。为什么?
class ClassWithOneInt {
var myInt = Int()
init(myInt: Int) {
self.myInt = Int()
}
func encodeWithCoder(aCoder: NSCoder) {
aCoder.encodeObject(myInt, forKey: "myInt")
}
init(coder aDecoder: NSCoder) {
self.myInt = aDecoder.decodeObjectForKey("myInt") as Int
}
}
class ClassWithOneArray {
var myArray = String[]()
init(myArray: String[]) {
self.myArray = String[]()
}
func encodeWithCoder(aCoder: NSCoder) {
aCoder.encodeObject(myArray, forKey: "myArray")
}
init(coder aDecoder: NSCoder) {
self.myArray = aDecoder.decodeObjectForKey("myArray") as String[]
}
}
【问题讨论】:
-
鉴于编译器正在崩溃,这很明显看起来像一个编译器错误。
-
好的,谢谢。我将提交错误报告。
-
这似乎用 Beta 2 编译器编译得很好。