异步Get方式

     // MARK: - 异步Get方式
     func asynchronousGet()
     {
         //创建NSURL对象
         var url:NSURL! = NSURL(string: "http://m.weather.com.cn/data/101010100.html")

         //创建请求对象
         var urlRequest : NSURLRequest = NSURLRequest(URL: url, cachePolicy: NSURLRequestCachePolicy.UseProtocolCachePolicy, timeoutInterval: )

         //连接服务器
         var connection = NSURLConnection(request: urlRequest, delegate: self)
     }

     // MARK: - NSURLConnectionDelegate : NSObjectProtocol {
     func connection(connection: NSURLConnection, didFailWithError error: NSError)
     {
         //请求失败
     }
     func connectionShouldUseCredentialStorage(connection: NSURLConnection) -> Bool
     {
         //连接应使用证书存储
         return true
     }
     func connection(connection: NSURLConnection, willSendRequestForAuthenticationChallenge challenge: NSURLAuthenticationChallenge)
     {
         //发送请求验证
     }
     func connection(connection: NSURLConnection, canAuthenticateAgainstProtectionSpace protectionSpace: NSURLProtectionSpace) -> Bool
     {
         //可以验证的保护空间
         return true
     }
     func connection(connection: NSURLConnection, didReceiveAuthenticationChallenge challenge: NSURLAuthenticationChallenge)
     {
         //获得认证
     }
     func connection(connection: NSURLConnection, didCancelAuthenticationChallenge challenge: NSURLAuthenticationChallenge)
     {
         //取消认证
     }
 

最新文章

  1. Get-FilewithExtension
  2. c#动态加载卸载DLL的方法
  3. Unity发送参数给iOSNative并响应
  4. Objective-c---分类 、 扩展 、 ARC
  5. 【BZOJ】【1025】【SCOI2009】游戏
  6. 【英语】Bingo口语笔记(38) - See系列
  7. Linux系统github使用
  8. 利用ADO方式连接SQLServer2008出现的问题
  9. Sublime text2 常用插件集锦
  10. Solr4.8.0源码分析(25)之SolrCloud的Split流程
  11. WEB工程数据库相关安装脚本写作
  12. openGL线s的绘制
  13. apollo实现c#与android消息推送(三)
  14. 这是我对GET与POST的区别的回答
  15. jsz中的作用域与上下文
  16. vxWorks6.6 N270 D525 cpu的bsp配置总结
  17. 学习任务,阅读一下Redis分布式锁的官方文档
  18. oracle 12C版本的下载安装
  19. python import引入不同路径下的模块
  20. Grafana 监控系统是否重启

热门文章

  1. Android 中屏幕点击事件的实现
  2. http://jingyan.baidu.com/article/4dc40848e7b69bc8d946f127.html
  3. 翻译【ElasticSearch Server】第一章:开始使用ElasticSearch集群(6)
  4. UITextView 不左上角显示
  5. Multiple View Geometry in Computer Vision Second Edition by Richard Hartley 读书笔记(一)
  6. 获取本机外网IP的方式笔记
  7. 仿酷狗音乐播放器开发日志二十四 选项设置窗体的实现(附328行xml布局源码)
  8. qt 获取天气的接口
  9. wuzhicms访问统计实现方法
  10. <问题>Eclipse中Deploy应用到GAE的错误