BaceModel

时间:2016-04-03 13:10:52   收藏:0   阅读:151

https://github.com/nicklockwood/BaseModel

字典封装成model 自动封装

要求属性的名字与字典一样

不能有对象

如果其中有需要自己封装的对象属性

重写setWithDictionary

 

-(void)setWithDictionary:(NSDictionary *)dict{

    [super setWithDictionary:dict];

    //user

    self.WBuser = [WeiboUser userWithDictionary:[dict objectForKey:@"user"]];

    //retweetWeibo

    if ([dict objectForKey:@"retweeted_status"] != nil) {

        WeiboModel *retModel = [[WeiboModel alloc] init];

        [retModel setWithDictionary:[dict objectForKey:@"retweeted_status"]];

        self.retweetedWeiboModel = retModel;

    }

 

}

原文:http://www.cnblogs.com/huoran1120/p/5349601.html

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!