请先看前一篇文章<移动互联网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. BZOJ2337: [HNOI2011]XOR和路径

    题解: 异或操作是每一位独立的,所以我们可以考虑每一位分开做. 假设当前正在处理第k位 那令f[i]表示从i到n 为1的概率.因为不是有向无环图(绿豆蛙的归宿),所以我们要用到高斯消元. 若有边i-& ...

  2. windows2003 IIS6网络负载平衡设置

    问题 随着计算机技术的不断发展,单台计算机的性能和可靠性越来越高.但现实中还是有许多应用是单台计算机难以达到,例如: 1.银行存储用户数据的数据库服务器必须保证24小时不间断的运转,并在发生严重硬件故 ...

  3. vc2005编译ffmpeg以及ffplay

    ffmpeg编译过程:1 http://ffmpeg.zeranoe.com/builds/下载官方提供的源码,win32库和dll.2 新建vc2005 console空工程,把ffmpeg.h,f ...

  4. Tomcat 调优总结

    一. jvm参数调优 常见的生产环境tomcat启动脚本里常见如下的参数,我们依次来解释各个参数意义. export JAVA_OPTS="-server -Xms1400M -Xmx140 ...

  5. distinct数据去重关键字

    在表中,可能会包含重复值.这并不成问题,不过,有时您也许希望仅仅列出不同(distinct)的值.关键词 distinct用于返回唯一不同的值. 表A: 示例1 select distinct nam ...

  6. 关于KOBE 退役

    今天在网上看到一行话,写在KOBE 退役之际 关于职业,最值得问的是自己我有没有像科比那样始终表现出对团队的忠诚和对职业的热爱?从不被别人的误解和攻击打倒?在团队最困难的时候站出来做能做的一切?用职业 ...

  7. Maximum Product Subarray JAVA实现

    题目描述: Find the contiguous subarray within an array (containing at least one number) which has the la ...

  8. Strom-7 Storm Trident 详细介绍

    一.概要 1.1 Storm(简介)      Storm是一个实时的可靠地分布式流计算框架.      具体就不多说了,举个例子,它的一个典型的大数据实时计算应用场景:从Kafka消息队列读取消息( ...

  9. Metaspace 之二--Java 8的元空间(metaspace)、metaspace监控方法

    很多开发者都在其系统中见过“java.lang.OutOfMemoryError: PermGen space”这一问题.这往往是由类加载器相关的内存泄漏以及新类加载器的创建导致的,通常出现于代码热部 ...

  10. Winform之SpreadSheetGear转DevExpress.XtraSpreadsheet.v13.2 z

    DevExpress.XtraSpreadsheet.v13.2 允许用户创建.管理.打印.转换spreadsheet文件而不需要用户安装Office. 什么是Spreadsheet 可以看到最后就是 ...