请先看前一篇文章<移动互联网app业务逻辑图>,以便于理解

http://blog.csdn.net/uxyheaven/article/details/14156659

1 start

- (IBAction)clickStart:(id)sender {
for (int i = 0; i < 6; i++) {
UILabel *label = (UILabel *)[self.view viewWithTag:i + 10000];
label.textColor = [UIColor blueColor];
} [self performSelector:@selector(start) withObject:nil afterDelay:1];
}

2 发送请求

-(void) httpGET{
UILabel *label = (UILabel *)[self.view viewWithTag:1 + 10000];
label.textColor = [UIColor redColor];
__block id myself =self;
HttpRequest *request = [self.entityModel.requestHelper get:@"api/nodes.json"];
[request succeed:^(HttpRequest *op) {
UILabel *label = (UILabel *)[self.view viewWithTag:2 + 10000];
label.textColor = [UIColor redColor]; if([op isCachedResponse]) {
NSLog(@"Data from cache %@", [op responseString]);
[myself parseData:[op responseString] isCachedResponse:YES];
}
else {
NSLog(@"Data from server %@", [op responseString]);
[myself parseData:[op responseString] isCachedResponse:NO];
}
} failed:^(HttpRequest *op, NSError *err) {
NSString *str = [NSString stringWithFormat:@"Request error : %@", [err localizedDescription]];
NSLogD(@"%@", str); // SHOWMBProgressHUD(@"Message", str, nil, NO, 3);
[self loadFromDBProcess];
}]; [self.entityModel.requestHelper submit:request];
}

3 解析请求

-(void) parseData:(NSString *)str isCachedResponse:(BOOL)isCachedResponse{
UILabel *label = (UILabel *)[self.view viewWithTag:3 + 10000];
label.textColor = [UIColor redColor]; self.model = [str toModels:[RubyChinaNodeEntity class]]; [self performSelector:@selector(refreshUI) withObject:nil afterDelay:1]; if (isCachedResponse) {
;
}else{
[self performSelector:@selector(saveToDBProcess) withObject:nil afterDelay:1];
}
}

4 持久化

-(void) saveToDBProcess{
UILabel *label = (UILabel *)[self.view viewWithTag:4 + 10000];
label.textColor = [UIColor redColor];
PERF_ENTER_( saveAllToDB )
[self.model saveAllToDB];
PERF_LEAVE_( saveAllToDB )
}

5 刷新UI

-(void) refreshUI{
UILabel *label = (UILabel *)[self.view viewWithTag:5 + 10000];
label.textColor = [UIColor redColor]; if (self.model && self.model.count > 0) {
NSString *str = [[self.model objectAtIndex:0] YYJSONString];
SHOWMBProgressHUD(@"Data", str, nil, NO, 3);
}
}

6 读取数据库

-(void) loadFromDBProcess{
self.model = [NSArray loadFromDBWithClass:[RubyChinaNodeEntity class]]; [self performSelector:@selector(refreshUI) withObject:nil afterDelay:1];
}

具体代码请在

https://github.com/uxyheaven/XYQuickDevelop

BusinessVC中查看

ios 移动应用通用逻辑流程的更多相关文章

  1. iOS Universal Links(通用链接)

    公司的运维,发现最近大量的请求 /.well-known/apple-app-site-association这个文件,造成了大量的404,可是这是谁请求的呢? 其实是苹果从iOS9.3开始更改了通用 ...

  2. iOS 9学习系列:打通 iOS 9 的通用链接(Universal Links)

    在WWDC 2015 上, Apple 为 iOS 9 宣布了一个所谓 通用链接 的深层链接特性, 视频地址为 [无缝链接到您的 App].虽然它不是一个必须实现的功能, 但还是需要引起一些注意. 在 ...

  3. Linux中断(interrupt)子系统之四:驱动程序接口层 & 中断通用逻辑层【转】

    转自:http://blog.csdn.net/droidphone/article/details/7497787 在本系列文章的第一篇:Linux中断(interrupt)子系统之一:中断系统基本 ...

  4. fir.im Weekly - iOS开发中的Git流程

    本期 fir.im Weekly 收集了微博上的热转资源,包含 Android.iOS 开发工具.源码等好用的轮子,还有一些 APP 设计的 Tips,希望对你有用. 精仿知乎日报 iOS 端 @我偏 ...

  5. 在Salesforce中通过 Debug Log 方式 跟踪逻辑流程

    在Salesforce中通过 Debug Log方式 跟踪逻辑流程 具体位置如下所示: Setup ---> Logs ---> Debug Logs ---> Monitored ...

  6. 李洪强iOS开发Swift篇—06_流程控制

    李洪强iOS开发Swift篇—06_流程控制 一.swift中的流程控制 Swift支持的流程结构如下: 循环结构:for.for-in.while.do-while 选择结构:if.switch 注 ...

  7. iOS项目生成通用Windows应用

    WinObjc - 使用iOS项目生成通用Windows应用   Github上一周年的WinObjc项目最近发布了预览版本,终于等到了这一天.WinObjc项目就是Build 2015大会上微软宣布 ...

  8. HDFS追本溯源:HDFS操作的逻辑流程与源码解析

    本文主要介绍5个典型的HDFS流程,这些流程充分体现了HDFS实体间IPC接口和stream接口之间的配合. 1. Client和NN Client到NN有大量的元数据操作,比如修改文件名,在给定目录 ...

  9. <iOS开发>之App上架流程(2017)

    本文主要介绍了App上架流程,以及上架过程中会遇到的一些问题. 一.App上架前的准备. 上架前,需要开发人员有苹果开发者账号,具体请阅读苹果开发者账号注册申请流程.本文是在已经拥有开发者账号的前提下 ...

随机推荐

  1. WPF 用 DataTemplate 合并DataGrid列表列头<类似报表设计>及行头列头样式 - 学习

    WPF中 DataGrid 列头合并,类似于报表设计.效果图如下↓ 1.新建一个WPF项目WpfApplication1,新建一个窗体DataGridTest,前台代码如下: <Window x ...

  2. sharepoint Linq方式的增,删,查,改

    Site9527EntitiesDataContext (重要的类):连接实体与网站List操作 SPContext.Current.Web.Url:获取当前操作的页面 FirstOrDefault: ...

  3. ASP.NET Redis 开发(转载)

    Redis简介 Redis是一个开源的,使用C语言编写,面向“键/值”对类型数据的分布式NoSQL数据库系统,特点是高性能,持久存储,适应高并发的应用场景.Redis纯粹为应用而产生,它是一个高性能的 ...

  4. Discuz 7.2 /faq.php SQL注入漏洞

    测试方法: 提供程序(方法)可能带有攻击性,仅供安全研究与教学之用,风险自负!   Discuz 7.2 /faq.php SQL注入漏洞   http://www.xxx.com/faq.php?a ...

  5. MasterPage的自身Bug还是?

    如果不想每个页面都设置css样式,那就在MasterPage设置即可,但是有个问题就是路径并不能识别正确,所以必须让你的页面和MasterPage的页面在平级的位置. 例如MasterPage.mas ...

  6. JavaScript学习笔记(备忘录)

    ===运算符 判断数值和类型是否相等.如: console.log('s'==='s') //输出trueconsole.log('1'===1) //输出false

  7. 我的web前端之路 分享些前端的好书(转)

    WEB前端研发工程师,在国内算是一个朝阳职业,这个领域没有学校的正规教育,大多数人都是靠自己自学成才.本文主要介绍自己从事web开发以来 (从大二至今)看过的书籍和自己的成长过程,目的是给想了解Jav ...

  8. handler.post 为什么要将thread对象post到handler中执行呢?

    转载网址:http://www.cnblogs.com/crazypebble/archive/2011/03/23/1991829.html在Android中使用Handler和Thread线程执行 ...

  9. Linux下的sniffer工具--TcpDump的安装和使用

    在如今众多的黑客技术中,嗅探器(sniffer)是最常见,也是最重要的技术之一. 用过windows平台上的sniffer工具(例如,netxray和sniffer pro软件)的朋友可能都知道,在共 ...

  10. hadoop2.0中无法启动datanode的问题

    问题描述:在启动datanode进程时,能成功的启动:但用jps查看进程时,发现进程不存在,下面是在datanode日记文件的错误信息 如下图的截屏所示: 主要原因:发生错误的原因:由于把data放在 ...