当我用更大的枚举实例替换枚举时,我似乎遇到了错误。它可以作为一个快速的游乐场运行,但当我在iOS设备上运行时,我收到malloc
错误:
enum E {
case small
case big(foo:[Int])
mutating func swap(with e:E) {
self = e //malloc: *** error for object 0x13805d000: incorrect checksum for freed object - object was probably modified after being freed.
}
}
var i = [Int](1...100000)
var a = E.small
var b = E.big(foo:i)
a.swap(with:b)
为什么行self = e
会出现运行时错误?