Calling the toJSONString method with UIColor.clear will result in an error
- Dominant language
- Swift
- Stars
- 4.3k
- Forks
- 677
- PR merge metrics
- No merged PRs in 30d
Description
### Question
Calling toJSONString after creating an object with the UIColor.clear property reports an error and fails to serialize successfully.
### Code
```swift
class SandBoxModel: HandyJSON {
var mode: Int = 0
var color: UIColor = .clear
func mapping(mapper: HelpingMapper) {
mapper <<<
color <-- HexColorTransform()
}
public required init() {}
}
var model = SandBoxModel()
model.color = .clear
if let jsonString = model.toJSONString {
print(jsonString)
}
```
### Error
`Swift/ContiguousArrayBuffer.swift:580: Fatal error: Index out of range`
Contributor guide
No contributing guide indexed for this repository
Research direction
Reproduce issue #486 with the provided SandBoxModel, UIColor.clear, and HexColorTransform, starting at the toJSONString entry point. Trace the serialization path for the clear color and compare it with other UIColor values. Done means the example no longer triggers an index-out-of-range failure and serializes successfully.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- swift
- Domain
- api
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100