swift 5.0\xcode10.2 Swift字典无法正确映射的模型
- Dominant language
- Swift
- Stars
- 4.3k
- Forks
- 677
- PR merge metrics
- No merged PRs in 30d
Description
这是我的字典:
```Swift
let value: [String: Float] = ["vectors": [1.0, 2.0]] as [String: Any]
struct VectorModel: HandyJSON {
var vectors: [CGFloat] = []
}
// 错误的取值
let model = VectorModel.deserialize(from: value)
// model.vectors 的值为 []
// 正确的取值
let model = VectorModel.deserialize(from: NSDictionary.init(dictionary: value))
```
不知道是不是和字典的类型有关?
Contributor guide
No contributing guide indexed for this repository
Research direction
Start with the reported calls to VectorModel.deserialize(from:) and compare passing the Swift dictionary with passing NSDictionary.init(dictionary: value). Check whether the vectors field maps to [CGFloat] in both cases; done means the Swift dictionary produces the same expected [1.0, 2.0] value as the NSDictionary input.
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