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上架前的准备. 上架前,需要开发人员有苹果开发者账号,具体请阅读苹果开发者账号注册申请流程.本文是在已经拥有开发者账号的前提下 ...
随机推荐
- MasterPage的自身Bug还是?
如果不想每个页面都设置css样式,那就在MasterPage设置即可,但是有个问题就是路径并不能识别正确,所以必须让你的页面和MasterPage的页面在平级的位置. 例如MasterPage.mas ...
- mk文件剖析
一个Android.mk file用来向编译系统描述你的源代码.具体来说:该文件是GNU Makefile的一小部分,会被编译系统解析一次或多次.你可以在每一个Android.mk file中定义一个 ...
- I.MX6 bq27441 driver porting
/************************************************************************** * I.MX6 bq27441 driver p ...
- 【Java学习笔记】Hello world
package aaa; public class aaa { public static void main(String args[]){ System.out.println("hel ...
- 【C#学习笔记】LinkedList容器使用
using System; using System.Collections.Generic; namespace ConsoleApplication { class Program { stati ...
- Struts2中date标签乱码问题解决
1.出现的问题如下图 八月份以前没有问题,但从九月份开始就会出现乱码问题 2.开始解决 (1)在使用标签的JSP中加入: <%@taglib prefix="s" uri=& ...
- fastdb中的位图应用
位图内存管理: 每块内存用一个二进制位表示它的使用状态,如果该块内存被占用,则把对应位图中的对应位置1,如果空闲则置0,原理十分简单.计算机里面处理的位数最少的变量是字节(byte),所以也就是8位做 ...
- Devexpress DateEdit选年月 z
Mask与Display只显示年月2012-02这种格式,但用户选择起来还是不爽,体验太差. 效果如下: 代码: using Microsoft.VisualBasic; using System; ...
- 从windows转向mac
键盘问题: 按键对应表 Windows Mac ctrl command alt option 由此可推断,windows下的ctrl+c/v 变成了mac下的 command+c/v 功能对应表 删 ...
- bzoj 1109 [POI2007]堆积木Klo(LIS)
[题意] n个数的序列,删除一个数后序列左移,求最后满足i==a[i]的最大个数. [思路] 设最终得到a[i]==i的序列为s,则s应满足: i<j,a[i]<a[j],i-a[i]&l ...