alibaba / alibaba/HandyJSON

在mapping方法中做字段映射时 TransofrmOf初始化方法的回调不执行

Open
#181 5 comments 0 reactions 0 assignees View on GitHub
Dominant language
Swift
Stars
4.3k
Forks
677
PR merge metrics
No merged PRs in 30d

Description

```swift
class SearchNewsCellModel: HandyJSON {

var title:String? //标题
var content:String? //内容
var attrTitle: NSAttributedString?
var attrContent: NSAttributedString?

func mapping(mapper: HelpingMapper) {
mapper <<<
self.attrTitle <-- TransformOf(fromJSON: { (string) -> NSAttributedString? in
return self.title?.parseTitle()
}, toJSON: { (NSAttributedString) -> String? in
return nil
})

mapper <<<
self.attrContent <-- TransformOf(fromJSON: { (string) -> NSAttributedString? in
return self.content?.parseContent()
}, toJSON: { (NSAttributedString) -> String? in
return nil
})
}

}
```
fromJSON,toJSON这个两个闭包不执行, mapping函数能进入,版本是handyJSON1.8.0,Xcode9编译,swift版本3.2

Contributor guide

No contributing guide indexed for this repository

Research direction

The entry point is mapping(mapper:) with TransformOf in the supplied SearchNewsCellModel example; first reproduce it with HandyJSON 1.8.0 under Swift 3.2 and trace whether the callbacks are registered. Done means the fromJSON and toJSON closures execute during the relevant mapping operations.

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.