Giter VIP home page Giter VIP logo

qybasemodel's Introduction

##QYBaseModel

  • The easy way to parse json
  • 简单易用的数据模型解析工具

##如何使用QYBaseModel

  • 将QYBaseModel导入项目,因为该文件不支持arc所以需要在Build Phases-Compile Sourcese-QYBaseModel.m文件后面添加“-fno-objc-arc”
  • 新建model数据模型的时候继承QYBaseModel即可

##使用注意

  • 如果json数据中有字段为关键字的时候,可以再model中自定义属性名,然后在在model.m中重写父类- (id)initContentWithDic:方法在这里为该方法赋值
  • 如果json中还有数组或者字典则可以用类此的方法继续解析
- (id)initContentWithDic:(NSDictionary *)dic
{
    if (self = [super initContentWithDic:dic]) {
        // 解析works,以及avatars,为actorId赋值
        self.actorId = dic[@"id"];
 
        NSMutableArray *workModels = [NSMutableArray array];
        for (NSDictionary *workDict in _works) {
            WorkModel *workModel = [[WorkModel alloc] initContentWithDic:workDict];
            [workModels addObject:workModel];
        }
        self.works = workModels;
        
        self.avatars = [[AvatarModel alloc] initContentWithDic:dic[@"avatars"]];
    }
    return self;
}

qybasemodel's People

Stargazers

qianye avatar  avatar

Watchers

James Cloos avatar qianye avatar

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.