-(NSDictionary*)attributeMapDictionary
{
NSDictionary *dic = @{
@"created_at" : @"created_at",
@"weiboID" : @"id",
@"text" : @"text",
@"source" : @"source",
@"favorited" : @"favorited",
@"thumbnail_pic" : @"thumbnail_pic",
@"bmiddle_pic" : @"bmiddle_pic",
@"original_pic" : @"original_pic",
@"geo" : @"geo",
@"reposts_count" : @"reposts_count",
@"comments_count" : @"comments_count",
@"attitudes_count" : @"attitudes_count"
};
return dic;
}
-(void)setAttributes:(NSDictionary*)dataDic
{
[super setAttributes:dataDic];
//处理2个特殊字段的映射, 两个对象
//转发微博的字典
NSDictionary *retweetedDic = [dataDic objectForKey:@"retweeted_status"];
//递归退出的条件
if (retweetedDic) {
//把转发的微博字典映射成Model对象
WeiboModel *retweetedWeibo = [[WeiboModel alloc] initWithDataDic:retweetedDic];
self.retweeted_weibo = retweetedWeibo;
[retweetedWeibo release];
}
//用户字典
NSDictionary *userDic = [dataDic objectForKey:@"user"];
if (userDic) {
UserModel *userModel = [[UserModel alloc] initWithDataDic:userDic];
self.user = userModel;
[userModel release];
}
}
@end
WXModel微博使用2个方法
最新推荐文章于 2022-10-20 19:09:12 发布