ios 移动应用通用逻辑流程
来源:互联网 发布:key查看器软件 编辑:程序博客网 时间:2024/05/16 14:09
请先看前一篇文章<移动互联网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中查看
0 0
- ios 移动应用通用逻辑流程
- ios 移动应用通用逻辑流程
- 移动应用开发(IOS/android等)中一个通用的图片缓存方案讲解
- 移动应用设计基本流程
- IOS 移动应用更新
- Web应用自安装逻辑流程
- ios 应用 开发流程。。。
- ios应用发布流程
- iOS应用发布流程
- iOS 应用发布流程
- iOS 应用发布流程
- iOS 应用发布流程
- iOS 应用发布流程
- iOS应用发布流程
- ios应用启动流程
- iOS 应用发布流程
- iOS 应用发布流程
- ios应用发布流程
- 内核memblock的知识
- nodejs安装
- iWatch零部件开始量产 环旭电子或大幅受益
- spring mvc用rest注解时的文件上传和参数传递
- 苹果OS X全新界面及iOS 8或将在WWDC上揭晓
- ios 移动应用通用逻辑流程
- Python:AttributeError: 'function' object has no attribute '_doc_'
- B. Prison Transfer
- ASP.NET 实现重写重写 Url Rewriting详解
- Abstract Factory 抽象工厂模式
- wpf 无边框窗体无法响应MouseMove事件
- 微软CEO纳德拉若弃Xbox,比尔盖茨也同意
- 滚动地图的实现
- 如何编写nand驱动,360doc比较详细