一: 三个常用的框架

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. 简单了解.net

    .NET是 Microsoft XML Web services 平台.XML Web services 允许应用程序通过 Internet 进行通讯和共享数据,而不管所采用的是哪种操作系统.设备或编 ...

  2. Java堆和栈详解

    Java把内存分成两种,一种叫做栈内存,一种叫做堆内存 在函数中定义的一些基本类型的变量和对象的引用变量都是在函数的栈内存中分配.当在一段代码块中定义一个变量时,java就在栈中为这个变量分配内存空间 ...

  3. iframe显示错误页面

    当系统出现异常时,ifrme中显示的内容为错也页面,而不是罪顶层的框架显示错误内容,此时的解决办法是在错误页面或相关的登录页面中加入 错误页面加载的JS如下 <script type=" ...

  4. 【Nginx】配置Nginx的负载均衡

    参考的优秀文章 tomcat配置文件server.xml详解 AJP协议总结与分析 Using nginx as HTTP load balancer 在本机运行2个Tomcat 现需要运行两个Tom ...

  5. SpringMVC控制器与视图的数据交换

    1,先创建spring的主配置文件(applicationContaxt.xml如果写在WEB-INF下,就不用配置context了,就是不用告诉它路径了,WEB-INF会自动加载的),由监听器负责加 ...

  6. createjs 更新

    使用0.8.2版本 不在需要单独 引入 MovieClip 文件了

  7. Nginx模块之————RTMP模块的FFmpeg的配置问题是FFmpeg的连续退出

    rtmp { server { listen ; application live { allow publish all; allow play all; live on; exec /root/b ...

  8. 程序设计入门——C语言 第5周编程练习 1高精度小数(10分)

    1 高精度小数(10分) 题目内容: 由于计算机内部表达方式的限制,浮点运算都有精度问题,为了得到高精度的计算结果,就需要自己设计实现方法. (0,1)之间的任何浮点数都可以表达为两个正整数的商,为了 ...

  9. Error: Cannot find a valid baseurl for repo: base

    解决方法如下(修改dns配置) vi /etc/resolv.conf 在此文件最后加入:nameserver 8.8.8.8 如果没有vi编辑器可用: echo "nameserver 8 ...

  10. django"动态网页","动态url","调试方法"

    一.动态网页 其实只是每次刷新时,获取最新时间而已 1.urls.py from django.conf.urls import patterns, url, include urlpatterns ...