关于被@objc标记的enum 报错的问题 -[__SwiftValue longLongValue]: unrecognized selector sent to instance 0x600001af8180
- Dominant language
- Swift
- Stars
- 4.3k
- Forks
- 677
- PR merge metrics
- No merged PRs in 30d
Description
@objc enum TestType: Int, HandyJSONEnum {
case none = 0
case type = 1
case type2 = 2
}
class TestData: HandyJSON {
@objc var data: Int = 0
@objc var type: TestType = .none
}

需求是:
我们OC、Swift混合开发,OC中需要使用Swift中的枚举,因此枚举被标记为@objc,但是这时解析json数据时就会报上面的错误。
我目前的解决方法是修改HandyJSON源码:

请问这个目前有什么好的解决方案吗?还是我没找到正确的方案?
Contributor guide
No contributing guide indexed for this repository
Research direction
Start with the @objc enum TestType and the TestData.type property in the provided reproduction, then trace HandyJSON's JSON parsing path for enum properties. Reproduce the __SwiftValue longLongValue error with the shown model and JSON input; done means @objc-marked Int-backed enums deserialize without that exception.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- swift
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100