ios 移动应用通用逻辑流程
请先看前一篇文章<移动互联网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 移动应用通用逻辑流程的更多相关文章
- iOS Universal Links(通用链接)
公司的运维,发现最近大量的请求 /.well-known/apple-app-site-association这个文件,造成了大量的404,可是这是谁请求的呢? 其实是苹果从iOS9.3开始更改了通用 ...
- iOS 9学习系列:打通 iOS 9 的通用链接(Universal Links)
在WWDC 2015 上, Apple 为 iOS 9 宣布了一个所谓 通用链接 的深层链接特性, 视频地址为 [无缝链接到您的 App].虽然它不是一个必须实现的功能, 但还是需要引起一些注意. 在 ...
- Linux中断(interrupt)子系统之四:驱动程序接口层 & 中断通用逻辑层【转】
转自:http://blog.csdn.net/droidphone/article/details/7497787 在本系列文章的第一篇:Linux中断(interrupt)子系统之一:中断系统基本 ...
- fir.im Weekly - iOS开发中的Git流程
本期 fir.im Weekly 收集了微博上的热转资源,包含 Android.iOS 开发工具.源码等好用的轮子,还有一些 APP 设计的 Tips,希望对你有用. 精仿知乎日报 iOS 端 @我偏 ...
- 在Salesforce中通过 Debug Log 方式 跟踪逻辑流程
在Salesforce中通过 Debug Log方式 跟踪逻辑流程 具体位置如下所示: Setup ---> Logs ---> Debug Logs ---> Monitored ...
- 李洪强iOS开发Swift篇—06_流程控制
李洪强iOS开发Swift篇—06_流程控制 一.swift中的流程控制 Swift支持的流程结构如下: 循环结构:for.for-in.while.do-while 选择结构:if.switch 注 ...
- iOS项目生成通用Windows应用
WinObjc - 使用iOS项目生成通用Windows应用 Github上一周年的WinObjc项目最近发布了预览版本,终于等到了这一天.WinObjc项目就是Build 2015大会上微软宣布 ...
- HDFS追本溯源:HDFS操作的逻辑流程与源码解析
本文主要介绍5个典型的HDFS流程,这些流程充分体现了HDFS实体间IPC接口和stream接口之间的配合. 1. Client和NN Client到NN有大量的元数据操作,比如修改文件名,在给定目录 ...
- <iOS开发>之App上架流程(2017)
本文主要介绍了App上架流程,以及上架过程中会遇到的一些问题. 一.App上架前的准备. 上架前,需要开发人员有苹果开发者账号,具体请阅读苹果开发者账号注册申请流程.本文是在已经拥有开发者账号的前提下 ...
随机推荐
- bzoj3140
首先考虑二维的情况 min(x,y)也就意味着确定最小后,另外一维肯定打满 然后最小那个如果是k的话就相当于用k*1次——这不就是行列覆盖吗,二分图秒之 三维呢?考虑到a*b*c<=5000也就 ...
- MSSQL大全
一.基础 1.说明:创建数据库CREATE DATABASE database-name 2.说明:删除数据库drop database dbname3.说明:备份sql server--- 创建 备 ...
- 使用solrj操作solr索引库
(solrj)初次使用solr的开发人员总是很郁闷,不知道如何去操作solr索引库,以为只能用<五分钟solr4.5教程(搭建.运行)>中讲到的用xml文件的形式提交数据到索引库,其实没有 ...
- 多线程监控文件夹,FlieSystemWatcher,并使用共享函数
发表于: 2011-01-06 09:55:47 C# code ? 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 2 ...
- JAVA和C/C++之间的相互调用。
在一些Android应用的开发中,需要通过JNI和 Android NDK工具实现JAVA和C/C++之间的相互调用. Java Native Interface (JNI)标准是java平台的一部分 ...
- python学习资源
12岁的少年教你用Python做小游戏: http://blog.jobbole.com/46308/ python视频教程大全集: http://www.douban.com/group/topic ...
- java Ant 的使用
Apache Ant 1.7.0 is the best available version的下载地址:http://ant.apache.org/bindownload.cgi 部署: 参考JAVA ...
- SqlServer获取两个日期时间差
SELECT datediff(yy,'2010-06-1 10:10',GETDATE()) --计算多少年 SELECT datediff(q,'2011-01-1 10:10',GETDATE( ...
- ORA-15124 数据库启动阶段报错
重新进行启动数据库的时候报错: SQL> startup nomount; ORA-15124: ASM file name '+KEL/ipap/controlfile/control02.c ...
- 【跟我一起学Python吧】python学习摘要
开始靖,怒推一篇文章:码农平时应该注意的办公室礼节 学习一门脚本语言是很有必要的,当我们在开发一些简单,快速程序时,脚本语言便有了用武之地,而且还很給力.根据python的介绍,python是一门很简 ...