结构体中定义的属性不是可选的,但是解析的结果成了可选的属性
- Dominant language
- Swift
- Stars
- 4.3k
- Forks
- 677
- PR merge metrics
- No merged PRs in 30d
Description
pod 'HandyJSON', '~> 5.0.1'
struct UserInfoModel: HandyJSON {
var avatar: String!
var nick: String!
var username: String!
}
//主要问题在这里instance对应上面结构题的属性成了可选的
` static func _transform(dict: [String: Any]) -> _ExtendCustomModelType? {
var instance: Self
if let _nsType = Self.self as? NSObject.Type {
instance = _nsType.createInstance() as! Self
} else {
instance = Self.init()
}
instance.willStartMapping()
_transform(dict: dict, to: &instance)
instance.didFinishMapping()
return instance
}`
Contributor guide
No contributing guide indexed for this repository
Research direction
Start with the _transform(dict:) entry point shown in the issue and reproduce the case using the UserInfoModel example and HandyJSON 5.0.1. Trace the mapping into instance and compare the declared property types with the parsed result. Done means the declared non-optional model properties retain the expected type after deserialization, with a regression test covering this example.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- swift
- Domain
- data
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100