kakaopensource / KakaJSON

Fast conversion between JSON and model in Swift.
MIT License
1.16k stars 125 forks source link

enum 加@objc标签解析时会崩溃 #53

Open yelin1597532 opened 3 years ago

yelin1597532 commented 3 years ago

转换代码如下:

@objcMembers class CustomerQuestionTypeResp: NSObject, Convertible {

    @objc enum QuestionType: Int, ConvertibleEnum {
        case singleSelect = 0   
        case multiSelect = 1   
        case unsureSelect = 2   
        case judge = 3      
        case fillBlank = 4    
        case input = 5        
        case material = 6   
    }
    var type: QuestionType = .singleSelect

    required override init() {
        super.init()
    }
}

QuestionType在不标记@objc 的情况下解析正常,加了@objc标签后估计是偏移量有变化导致解析崩溃,崩溃位置如下: 截屏2020-12-22 上午11 39 55

BugsBiteBugs commented 3 years ago

我拿你这代码试了下,没发现问题

DamonHu commented 3 years ago

碰到了同样的报错,解析服务器返回的json数组时碰到了

syncList = responseData.kj.modelArray(LZNoteModel.self)

LZNoteModel的成员变量有一个enum含有@objc 标签,移除了没问题,加上就会出现这个报错

wolfcon commented 2 years ago

可能跟这个相关