关于ios网络杂记
来源:互联网 发布:js 左右滑动切换特效 编辑:程序博客网 时间:2024/04/29 05:58
网络程序的问题:
1. 随机断网
2.断点继续
3.网络不存在,如何处理中断,尤其是某个应用在有网络和无网络情况下多能够使用,请问该如何处理?
4.应该不存在最后确认的问题。
At WWDC2010, for network programming, Apple recommends to use asynchronous programming with RunLoop.
- WWDC 2010 Session 207 - Network Apps for iPhone OS, Part 1
- WWDC 2010 Session 208 - Network Apps for iPhone OS, Part 2
NSURLConnection asynchronous request is one of the most efficient way. But if you want to use ASIHTTPRequest, how about it? (ASIHTTPRequest asynchronous request is implemented using NSOperationQueue, it is not same as NSURLConnection asynchronous.)
ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:url];[request setCompletionBlock:^{ dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_LOW, 0), ^{ NSData *responseData = [request responseData]; /* Parse JSON, ... */ dispatch_async(dispatch_get_main_queue(), ^{ callbackBlock(array); }); });}];[request setFailedBlock:^{ NSError *error = [request error]; /* error handling */}];[request startAsynchronous];
通过notification来做,那请问如何保证,在你ready的时候,原来的picker view还在呢?也许被遮盖了,也许消失了。 how to balance these?
You can use NSNotificationCenter to post a notification to update the picker when the data has finished loading
Create the notification
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(refreshPicker) name: @"WEBSERVICE_UPDATED" object:nil];
Post the notification
[[NSNotificationCenter defaultCenter] postNotificationName:@"WEBSERVICE_UPDATED" object:lesson];-(void)refreshPicker { // Handle refresh here [pickerViewController reloadAllComponents];}
- 关于ios网络杂记
- iOS开发网络篇之:ASIHTTPRequest杂记
- iOS开发网络篇之:ASIHTTPRequest杂记
- 网络杂记
- 网络杂记
- iOS杂记
- iOS-杂记
- iOS杂记
- iOS 杂记
- IOS杂记
- 关于网络编程 (一)socket 杂记整理
- Linux网络杂记
- Linux网络杂记
- 网络基础杂记
- 关于iOS播放网络音频
- iOS:NSString 使用杂记
- ios UI 杂记
- ios多线程边学边杂记
- hdu 1060——Leftmost Digit
- Awk学习笔记
- 新闻模块的文章页面title怎么显示不同
- Coroutine介绍
- cc、gcc、g++、CC的区别概括
- 关于ios网络杂记
- awk 运算符(算术运算符,赋值运算符,关系运算符,逻辑运算符,正则运算符)说明
- OpenCV对像素的操作
- 关闭虚拟键盘的两种方式
- php 访问者模式代码学习
- PostMessage(异步)和SendMessage(同步)的区别
- android OnGestureListener简单认识DEMO
- ubuntu手动编译gvim7.3修复终端启动时与ibus的冲突
- opencv2.3.1 CvvImage类