HandyJSON 库的Crash问题

2018-10-11  本文已影响0人  古月思吉

工程使用了一个 HandyJSON 的库,升级到 Swift 4.1 后 Crash 了。

1.Crash 在:

var numberOfFields: Int {
    return Int(pointer.pointee.numberOfFields)
}
crash图.png

2.原因

3.解决办法:

var nominalTypeDescriptor: NominalTypeDescriptor? {
        let pointer = UnsafePointer<Int>(self.pointer)
        let base = pointer.advanced(by: nominalTypeDescriptorOffsetLocation)
        if base.pointee == 0 {
            // swift class created dynamically in objc-runtime didn't have valid nominalTypeDescriptor
            return nil
        }
        return NominalTypeDescriptor(pointer: relativePointer(base: base, offset: base.pointee - base.hashValue))
    }
解决图.png

参考文章:
https://zhuanlan.zhihu.com/p/35251092?edition=yidianzixun&utm_source=yidianzixun&yidian_docid=0Ii3ZJNz

上一篇下一篇

猜你喜欢

热点阅读