Code Monkey home page Code Monkey logo

Comments (6)

alfei13 avatar alfei13 commented on August 25, 2024

业务类的模型 继承自基类模型,这样情况想调用deserialize转换出来的就全是nil,麻烦大佬指点下

from smartcodable.

alfei13 avatar alfei13 commented on August 25, 2024

是否能像Handlyjson一样,不管是不是继承的model类,都能转换成功呢?

from smartcodable.

intsig171 avatar intsig171 commented on August 25, 2024

只要遵循了SmartCodable,就可以解析的。 不过继承的支持力度不够。 系统的Codable需要子类中重写init(decoder:)方法,并调用super.init(decoder). 详细见readme中的suggest模块的问答。

综合: 不建议使用继承来处理数据解析。 有任何问题可以加QQ群(readme最下面有QQ群截图)

from smartcodable.

alfei13 avatar alfei13 commented on August 25, 2024

原项目中基本都是继承自基类的,您意思是子类模型也要再次继承SmartCodable 就能解析么?

from smartcodable.

intsig171 avatar intsig171 commented on August 25, 2024

继承的实现比较麻烦,我在 继承 中有说明。

建议使用协议替代继承。 将公共的一些属性声明到一个协议中, 各个Model继承该协议,自然带有了公共的属性。

from smartcodable.

alfei13 avatar alfei13 commented on August 25, 2024

好的👌🏻,感谢大佬解惑;

from smartcodable.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.