一: 三个常用的框架

1. Mantle

- 所有模型必须继承MTModel

2. JSONModel

- 所有模型必须继承JSONModel

3.MJExtension

- 不需要继承任何东西。

- 代码:

//
// TableViewController.m
// json
//
// Created by Mac on 16/1/23.
// Copyright © 2016年 Mac. All rights reserved.
// #import "TableViewController.h"
#import <UIImageView+WebCache.h>
#import <MediaPlayer/MediaPlayer.h>
#import "ZZVideo.h"
#import <MJExtension.h>
@interface TableViewController ()
@property (nonatomic, strong) NSArray *videos; @end @implementation TableViewController - (void)viewDidLoad {
[super viewDidLoad];
NSURL *url = [NSURL URLWithString:@"http://120.25.226.186:32812/video"]; NSURLRequest *request = [NSURLRequest requestWithURL:url]; [NSURLConnection sendAsynchronousRequest:request queue:[NSOperationQueue mainQueue] completionHandler:^(NSURLResponse * _Nullable response, NSData * _Nullable data, NSError * _Nullable connectionError) {
NSDictionary *dic = [NSJSONSerialization JSONObjectWithData:data options:kNilOptions error:nil]; self.videos = [ZZVideo mj_objectArrayWithKeyValuesArray:dic[@"videos"]]; // NSLog(@"%zd",_videos.count);
[self.tableView reloadData];
}]; } #pragma mark - Table view data source - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
//#warning Incomplete implementation, return the number of sections
return ;
} - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
//#warning Incomplete implementation, return the number of rows
return self.videos.count;
} - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *ID = @"video"; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:ID]; ZZVideo *video = self.videos[indexPath.row]; cell.detailTextLabel.text = [NSString stringWithFormat:@"视频时长: %ld",(long)video.length]; cell.textLabel.text= video.name; NSString *image = [@"http://120.25.226.186:32812" stringByAppendingPathComponent:video.image]; [cell.imageView sd_setImageWithURL:[NSURL URLWithString:image] placeholderImage:nil]; return cell;
}
#pragma mark - 代理
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
ZZVideo *video = self.videos[indexPath.row]; NSString *videoStr = [@"http://120.25.226.186:32812" stringByAppendingPathComponent:video.url]; MPMoviePlayerViewController *vc = [[MPMoviePlayerViewController alloc] initWithContentURL:[NSURL URLWithString:videoStr]]; [self presentViewController:vc animated:YES completion:nil]; }
@end

二: 设计第三方框架需要考虑的地方

1.侵入性:

- 侵入性大就意味着项目很难离开这个框架

2.易用性

- 比如少量代码就可以实现很多功能

3.扩展性

- 很容易给框架增加新的功能

2016 - 1 - 23 json转模型 常用的第三方框架的更多相关文章

  1. iOS开发常用的第三方框架

    1. AFNetworking 在众多iOS开源项目中,AFNetworking可以称得上是最受开发者欢迎的库项目.AFNetworking是一个轻量级的iOS.Mac OS X网络通信类库,现在是G ...

  2. Swift 项目中常用的第三方框架

    Swift 项目中可能用到的第三方框架 字数1004 阅读4091 评论17 喜欢93 这里记录下swift开发中可能用的框架 , 最近浏览了不少,积累在这里,以后用的时候方便查阅.顺便推荐给大家! ...

  3. 2016 - 1 - 23 json解析

    一: json   1. 什么是json 1.1 json是一种轻量级的数据格式,一般用于数据交互. 1.2 服务器返回给客户端的数据,一般都是JSON或者XML格式(文件下载除外).   2. JS ...

  4. 探索ASP.NET MVC5系列之~~~4.模型篇---包含模型常用特性和过度提交防御

    其实任何资料里面的任何知识点都无所谓,都是不重要的,重要的是学习方法,自行摸索的过程(不妥之处欢迎指正) 汇总:http://www.cnblogs.com/dunitian/p/4822808.ht ...

  5. SQL Server 2016原生支持JSON

    转载原地址: http://www.cnblogs.com/lyhabc/p/4747694.html SQL Server 2005 开始支持 XML 数据类型,提供原生的 XML数据类型.XML ...

  6. Java基础-Java中23种设计模式之常用的设计模式

    Java基础-Java中23种设计模式之常用的设计模式 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任.   一.设计模式分类 设计模式是针对特定场景给出的专家级的解决方案.总的来说设 ...

  7. Gson Json 序列号 最常用的功能 MD

    Markdown版本笔记 我的GitHub首页 我的博客 我的微信 我的邮箱 MyAndroidBlogs baiqiantao baiqiantao bqt20094 baiqiantao@sina ...

  8. Murano Weekly Meeting 2016.08.23

    Meeting time: 2016.August.23 1:00~2:00 Chairperson:  Kirill Zaitsev, from Mirantis Meeting summary: ...

  9. Django ORM (一) 创建数据库和模型常用的字段类型参数及Field 重要参数介绍

    创建一个 Django 项目及应用 django-admin startproject orm cd orm python manage.py startapp app01 在 models.py 上 ...

随机推荐

  1. bat命令

    将DIR设置为当前文件所在的绝对路径 @echo off echo 当前盘符:%~d0 echo 当前盘符和路径:%~dp0 echo 当前盘符和路径的短文件名格式:%~sdp0 echo 当前批处理 ...

  2. 【转】Struts1.x系列教程(5):HTML标签库

    转载地址:http://www.blogjava.net/nokiaguy/archive/2009/01/archive/2009/01/archive/2009/01/archive/2009/0 ...

  3. 【转】Struts1.x系列教程(4):标签库概述与安装

    转载地址:http://www.blogjava.net/nokiaguy/archive/2009/01/archive/2009/01/archive/2009/01/archive/2009/0 ...

  4. [课程设计]Scrum 1.7 多鱼点餐系统开发进度(点餐菜式内容添加及美化)

    [课程设计]Scrum 1.7 多鱼点餐系统开发进度(点餐菜式内容添加及美化) 1.团队名称:重案组 2.团队目标:长期经营,积累客户充分准备,伺机而行 3.团队口号:矢志不渝,追求完美 4.团队选题 ...

  5. 关于bootstrap

    http://www.runoob.com/bootstrap/bootstrap-buttons.html file:///C:/LiuHuan/bc-bootstrap/bc-bootstrap/ ...

  6. Jquery 复习练习(01)

    Jquery 复习练习 window.onload = function() {} == $(function() {}); 千万注意:js对象和jq对象的区别,这也是常常犯的错误 js对象举例: w ...

  7. Python数据分析之pandas学习

    Python中的pandas模块进行数据分析. 接下来pandas介绍中将学习到如下8块内容:1.数据结构简介:DataFrame和Series2.数据索引index3.利用pandas查询数据4.利 ...

  8. 针对高通BMS的研究 高通电量计

    点击打开链接 高通8064 8974 8926等pm芯片都集成了电量计,估计后续芯片都会一直存在,现在许多项目UI状态栏电池都有百分比显示,所以需要深入分析BMS有助于解决电量方面的BUG. 一: S ...

  9. phpstorm相关设置

    1, phpstorm安装好后在编辑页随便点哪里都能把光标移过去,类似于word的“即点即输”.仔细找了下,终于找出来怎么关闭了: 这一功能在phpstorm中不知道叫啥名,去掉方法是 打开File- ...

  10. C#程序设计---->计算圆面积windows程序

    值得说的就是添加一个回车事件, http://blog.csdn.net/nanwang314/article/details/6176604 private void textBox1_KeyDow ...