请先看前一篇文章<移动互联网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. win7x64下的redis安装与使用

    先引用百度百科的一段话吧,具体可以到百科查看吧. Redis是一个开源的使用ANSI C语言编写.支持网络.可基于内存亦可持久化的日志型.Key-Value数据库,并提供多种语言的API.从2010年 ...

  2. HDU 1213 How Many Tables (并查集,常规)

    并查集基本知识看:http://blog.csdn.net/dellaserss/article/details/7724401 题意:假设一张桌子可坐无限多人,小明准备邀请一些朋友来,所有有关系的朋 ...

  3. python - pip 从已有的安装列表 安装

    已经安装好的机器:sudo pip freeze > install_list.list 需要安装的机器:sudo pip install -r install_list.list

  4. 一天一个Java基础——数组

    一天一个变成了几天一个,最近接受的新东西太多.太快,有好多需要blog的但没有时间,这些基础知识应该是要深挖并好好研究的,不应该每次都草草了事,只看个皮毛. 数组: JVM将数组存储在一个称为堆(he ...

  5. TCP/IP详解学习笔记(4)-ICMP协议,ping和Traceroute

    1.IMCP协议介绍 前面讲到了,IP协议并不是一个可靠的协议,它不保证数据被送达,那么,自然的,保证数据送达的工作应该由其他的模块来完成.其中一个重要的模块就是ICMP(网络控制报文)协议. 当传送 ...

  6. hisi平台mii网络模式和rmii网络模式的uboot制作

    MII网络uboot编译说明 一:编译生成默认的uboot1. 进入到uboot目录a. cd /home/satan/Hi3518_SDK_V1.0.7.0/osdrv/uboot2. 新建临时文件 ...

  7. [Tommas] 一种有效的测试策略(转)

    在最近的一个大型项目中,我们在早期就定下了一个目标:不会在软件中使用大量QA人员专注于手工测试.通过手工测试发现bug极其耗时且成本高昂,这促使团队尝试尽可能的将质量内嵌到产品内部.但这并不意味着手工 ...

  8. 【windows核心编程】IO完成端口(IOCP)复制文件小例前简单说明

    1.关于IOCP IOCP即IO完成端口,是一种高伸缩高效率的异步IO方式,一个设备或文件与一个IO完成端口相关联,当文件或设备的异步IO操作完成的时候,去IO完成端口的[完成队列]取一项,根据完成键 ...

  9. JDBC中DAO事务函数模版

    DAO事物函数模版1: public void OrderFinsByPage(){ Connection conn = null; PreparedStatement pstmt = null; R ...

  10. 使用k-means对3D网格模型进行分割

    使用k-means对3D网格模型进行分割 由于一些原因,最近在做网格分割的相关工作.网格分割的方法有很多,如Easy mesh cutting.K-means.谱分割.基于SDF的分割等.根据对分割要 ...