AFNetworking了解

[-]

  1. 如何开始使用
  2. 综述
    1. CORE
    2. HTTP CLIENT
    3. IMAGES
  3. 例子程序
    1. XML REQUEST
    2. IMAGE REQUEST
    3. API CLIENT REQUEST
    4. FILE UPLOAD WITH PROGRESS CALLBACK
    5. STREAMING REQUEST

AFNetworking是一个讨人喜欢的网络库,适用于iOS以及Mac OS X. 它构建于在NSURLConnection, NSOperation, 以及其他熟悉的Foundation技术之上. 它拥有良好的架构,丰富的api,以及模块化构建方式,使得使用起来非常轻松.例如,他可以使用很轻松的方式从一个url来得到json数据:

<div class="devcodeoverflow" style="border: 1px solid rgb(204, 204, 204); vertical-align: baseline; background-color: transparent; margin: 1px !important; padding: 0px !important; outline: 0px !important; overflow: auto !important; float: none !important;"><table class="devcodearea  " width="100%"><tbody style="margin: 0px; padding: 0px; border: 0px; outline: 0px; overflow: visible; font-size: 12px; vertical-align: baseline; background-color: transparent;"><tr style="margin: 0px; padding: 0px; border: 0px; outline: 0px; overflow: visible; vertical-align: baseline; background-color: transparent;"><td class="devcodelines" width="1%" style="outline: 0px; overflow: visible; vertical-align: baseline; border-width: 0px 4px 0px 0px !important; border-right-style: solid !important; border-right-color: rgb(102, 238, 102) !important; padding: 0px 5px !important; margin: 0px !important; background-color: rgb(114, 158, 185) !important; font-family: 'courier new' !important; color: rgb(255, 255, 255) !important;">1</td><td class="devcodelinesarea" style="border-right-width: 0px; padding: 0px; margin: 0px; outline: 0px; overflow: visible; vertical-align: baseline; border-bottom-width: 0px !important; border-top-width: 0px !important; border-left-width: 0px !important;"><pre class="devcode devcodeline" name="code" style="white-space: pre-wrap; word-wrap: break-word; background-color: transparent; outline: 0px; overflow: visible; vertical-align: baseline; font-family: 'courier new' !important; border: 0px !important; padding: 0px 5px !important; margin-top: 0px !important; margin-bottom: 0px !important;"><span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; overflow: visible; vertical-align: baseline; background-color: transparent; color: rgb(64, 0, 128);">NSURL</span> <span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; overflow: visible; vertical-align: baseline; background-color: transparent; color: rgb(0, 34, 0);">*</span>url <span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; overflow: visible; vertical-align: baseline; background-color: transparent; color: rgb(0, 34, 0);">=</span> <span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; overflow: visible; vertical-align: baseline; background-color: transparent; color: rgb(0, 34, 0);">[</span><span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; overflow: visible; vertical-align: baseline; background-color: transparent; color: rgb(64, 0, 128);">NSURL</span> URLWithString<span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; overflow: visible; vertical-align: baseline; background-color: transparent; color: rgb(0, 34, 0);">:</span><span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; overflow: visible; vertical-align: baseline; background-color: transparent; color: rgb(191, 29, 26);">@</span><span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; overflow: visible; vertical-align: baseline; background-color: transparent; color: rgb(191, 29, 26);">"http://api.twitter.com/1/statuses/public_timeline.json"</span><span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; overflow: visible; vertical-align: baseline; background-color: transparent; color: rgb(0, 34, 0);">]</span>;
2
<span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; overflow: visible; vertical-align: baseline; background-color: transparent; color: rgb(64, 0, 128);">NSURLRequest</span> <span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; overflow: visible; vertical-align: baseline; background-color: transparent; color: rgb(0, 34, 0);">*</span>request <span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; overflow: visible; vertical-align: baseline; background-color: transparent; color: rgb(0, 34, 0);">=</span> <span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; overflow: visible; vertical-align: baseline; background-color: transparent; color: rgb(0, 34, 0);">[</span><span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; overflow: visible; vertical-align: baseline; background-color: transparent; color: rgb(64, 0, 128);">NSURLRequest</span> requestWithURL<span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; overflow: visible; vertical-align: baseline; background-color: transparent; color: rgb(0, 34, 0);">:</span>url<span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; overflow: visible; vertical-align: baseline; background-color: transparent; color: rgb(0, 34, 0);">]</span>;
3
AFJSONRequestOperation <span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; overflow: visible; vertical-align: baseline; background-color: transparent; color: rgb(0, 34, 0);">*</span>operation <span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; overflow: visible; vertical-align: baseline; background-color: transparent; color: rgb(0, 34, 0);">=</span> <span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; overflow: visible; vertical-align: baseline; background-color: transparent; color: rgb(0, 34, 0);">[</span>AFJSONRequestOperation JSONRequestOperationWithRequest<span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; overflow: visible; vertical-align: baseline; background-color: transparent; color: rgb(0, 34, 0);">:</span>request success<span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; overflow: visible; vertical-align: baseline; background-color: transparent; color: rgb(0, 34, 0);">:^</span><span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; overflow: visible; vertical-align: baseline; background-color: transparent; color: rgb(0, 34, 0);">(</span><span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; overflow: visible; vertical-align: baseline; background-color: transparent; color: rgb(64, 0, 128);">NSURLRequest</span> <span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; overflow: visible; vertical-align: baseline; background-color: transparent; color: rgb(0, 34, 0);">*</span>request, <span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; overflow: visible; vertical-align: baseline; background-color: transparent; color: rgb(64, 0, 128);">NSHTTPURLResponse</span> <span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; overflow: visible; vertical-align: baseline; background-color: transparent; color: rgb(0, 34, 0);">*</span>response, <span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; overflow: visible; vertical-align: baseline; background-color: transparent; color: rgb(166, 19, 144);">id</span> JSON<span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; overflow: visible; vertical-align: baseline; background-color: transparent; color: rgb(0, 34, 0);">)</span> <span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; overflow: visible; vertical-align: baseline; background-color: transparent; color: rgb(0, 34, 0);">{</span>
4
    NSLog<span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; overflow: visible; vertical-align: baseline; background-color: transparent; color: rgb(0, 34, 0);">(</span><span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; overflow: visible; vertical-align: baseline; background-color: transparent; color: rgb(191, 29, 26);">@</span><span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; overflow: visible; vertical-align: baseline; background-color: transparent; color: rgb(191, 29, 26);">"Public Timeline: %@"</span>, JSON<span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; overflow: visible; vertical-align: baseline; background-color: transparent; color: rgb(0, 34, 0);">)</span>;
5
<span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; overflow: visible; vertical-align: baseline; background-color: transparent; color: rgb(0, 34, 0);">}</span> failure<span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; overflow: visible; vertical-align: baseline; background-color: transparent; color: rgb(0, 34, 0);">:</span><span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; overflow: visible; vertical-align: baseline; background-color: transparent; color: rgb(166, 19, 144);">nil</span><span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; overflow: visible; vertical-align: baseline; background-color: transparent; color: rgb(0, 34, 0);">]</span>;
6
<span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; overflow: visible; vertical-align: baseline; background-color: transparent; color: rgb(0, 34, 0);">[</span>operation start<span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; overflow: visible; vertical-align: baseline; background-color: transparent; color: rgb(0, 34, 0);">]</span>;
 
 

如何开始使用

  • 下载 AFNetworking 然后尝试使用里面的例子
  • 阅读 “Getting Started” guide, FAQ, 或者 other articles in the wiki
  • 查看 完整的文档
  • 查看 NSScreencast episode about AFNetworking 来得到一个快速的参考,以快速的应用到你的app中
  • 有问题? Stack Overflow 是最好的地方来找到答案

综述

CORE:

AFURLConnectionOperation:一个 NSOperation 实现了NSURLConnection 的代理方法.

HTTP Requests:

AFHTTPRequestOperation:AFURLConnectionOperation的子类,当request使用的协议为HTTP和HTTPS时,它压缩了用于决定request是否成功的状态码和内容类型.

AFJSONRequestOperation:AFHTTPRequestOperation的一个子类,用于下载和处理jason response数据.

AFXMLRequestOperation:AFHTTPRequestOperation的一个子类,用于下载和处理xml response数据.

AFPropertyListRequestOperation:AFHTTPRequestOperation的一个子类,用于下载和处理property list response数据.

HTTP CLIENT:

AFHTTPClient:捕获一个基于http协议的网络应用程序的公共交流模式.包含:

  • 使用基本的url相关路径来只做request
  • 为request自动添加设置http headers.
  • 使用http 基础证书或者OAuth来验证request
  • 为由client制作的requests管理一个NSOperationQueue
  • 从NSDictionary生成一个查询字符串或http bodies.
  • 从request中构建多部件
  • 自动的解析http response数据为相应的表现数据
  • 在网络可达性测试用监控和响应变化.

IMAGES

AFImageRequestOperation:一个AFHTTPRequestOperation的子类,用于下载和处理图片.

UIImageView+AFNetworking:添加一些方法到UIImageView中,为了从一个URL中异步加载远程图片

例子程序

XML REQUEST

<div class="devcodeoverflow" style="border: 1px solid rgb(204, 204, 204); vertical-align: baseline; background-color: transparent; margin: 1px !important; padding: 0px !important; outline: 0px !important; overflow: auto !important; float: none !important;"><table class="devcodearea  " width="100%"><tbody style="margin: 0px; padding: 0px; border: 0px; outline: 0px; overflow: visible; font-size: 12px; vertical-align: baseline; background-color: transparent;"><tr style="margin: 0px; padding: 0px; border: 0px; outline: 0px; overflow: visible; vertical-align: baseline; background-color: transparent;"><td class="devcodelines" width="1%" style="outline: 0px; overflow: visible; vertical-align: baseline; border-width: 0px 4px 0px 0px !important; border-right-style: solid !important; border-right-color: rgb(102, 238, 102) !important; padding: 0px 5px !important; margin: 0px !important; background-color: rgb(114, 158, 185) !important; font-family: 'courier new' !important; color: rgb(255, 255, 255) !important;">1</td><td class="devcodelinesarea" style="border-right-width: 0px; padding: 0px; margin: 0px; outline: 0px; overflow: visible; vertical-align: baseline; border-bottom-width: 0px !important; border-top-width: 0px !important; border-left-width: 0px !important;"><pre class="devcode devcodeline" name="code" style="white-space: pre-wrap; word-wrap: break-word; background-color: transparent; outline: 0px; overflow: visible; vertical-align: baseline; font-family: 'courier new' !important; border: 0px !important; padding: 0px 5px !important; margin-top: 0px !important; margin-bottom: 0px !important;"><span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; overflow: visible; vertical-align: baseline; background-color: transparent; color: rgb(64, 0, 128);">NSURLRequest</span> <span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; overflow: visible; vertical-align: baseline; background-color: transparent; color: rgb(0, 34, 0);">*</span>request <span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; overflow: visible; vertical-align: baseline; background-color: transparent; color: rgb(0, 34, 0);">=</span> <span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; overflow: visible; vertical-align: baseline; background-color: transparent; color: rgb(0, 34, 0);">[</span><span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; overflow: visible; vertical-align: baseline; background-color: transparent; color: rgb(64, 0, 128);">NSURLRequest</span> requestWithURL<span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; overflow: visible; vertical-align: baseline; background-color: transparent; color: rgb(0, 34, 0);">:</span><span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; overflow: visible; vertical-align: baseline; background-color: transparent; color: rgb(0, 34, 0);">[</span><span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; overflow: visible; vertical-align: baseline; background-color: transparent; color: rgb(64, 0, 128);">NSURL</span> URLWithString<span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; overflow: visible; vertical-align: baseline; background-color: transparent; color: rgb(0, 34, 0);">:</span><span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; overflow: visible; vertical-align: baseline; background-color: transparent; color: rgb(191, 29, 26);">@</span><span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; overflow: visible; vertical-align: baseline; background-color: transparent; color: rgb(191, 29, 26);">"http://api.flickr.com/services/rest/?method=flickr.groups.browse&api_key=b6300e17ad3c506e706cb0072175d047&cat_id=34427469792%40N01&format=rest"</span><span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; overflow: visible; vertical-align: baseline; background-color: transparent; color: rgb(0, 34, 0);">]</span><span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; overflow: visible; vertical-align: baseline; background-color: transparent; color: rgb(0, 34, 0);">]</span>;
2
AFXMLRequestOperation <span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; overflow: visible; vertical-align: baseline; background-color: transparent; color: rgb(0, 34, 0);">*</span>operation <span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; overflow: visible; vertical-align: baseline; background-color: transparent; color: rgb(0, 34, 0);">=</span> <span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; overflow: visible; vertical-align: baseline; background-color: transparent; color: rgb(0, 34, 0);">[</span>AFXMLRequestOperation XMLParserRequestOperationWithRequest<span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; overflow: visible; vertical-align: baseline; background-color: transparent; color: rgb(0, 34, 0);">:</span>request success<span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; overflow: visible; vertical-align: baseline; background-color: transparent; color: rgb(0, 34, 0);">:^</span><span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; overflow: visible; vertical-align: baseline; background-color: transparent; color: rgb(0, 34, 0);">(</span><span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; overflow: visible; vertical-align: baseline; background-color: transparent; color: rgb(64, 0, 128);">NSURLRequest</span> <span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; overflow: visible; vertical-align: baseline; background-color: transparent; color: rgb(0, 34, 0);">*</span>request, <span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; overflow: visible; vertical-align: baseline; background-color: transparent; color: rgb(64, 0, 128);">NSHTTPURLResponse</span> <span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; overflow: visible; vertical-align: baseline; background-color: transparent; color: rgb(0, 34, 0);">*</span>response, <span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; overflow: visible; vertical-align: baseline; background-color: transparent; color: rgb(64, 0, 128);">NSXMLParser</span> <span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; overflow: visible; vertical-align: baseline; background-color: transparent; color: rgb(0, 34, 0);">*</span>XMLParser<span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; overflow: visible; vertical-align: baseline; background-color: transparent; color: rgb(0, 34, 0);">)</span> <span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; overflow: visible; vertical-align: baseline; background-color: transparent; color: rgb(0, 34, 0);">{</span>
3
  XMLParser.delegate <span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; overflow: visible; vertical-align: baseline; background-color: transparent; color: rgb(0, 34, 0);">=</span> self;
4
  <span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; overflow: visible; vertical-align: baseline; background-color: transparent; color: rgb(0, 34, 0);">[</span>XMLParser parse<span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; overflow: visible; vertical-align: baseline; background-color: transparent; color: rgb(0, 34, 0);">]</span>;
5
<span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; overflow: visible; vertical-align: baseline; background-color: transparent; color: rgb(0, 34, 0);">}</span> failure<span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; overflow: visible; vertical-align: baseline; background-color: transparent; color: rgb(0, 34, 0);">:</span><span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; overflow: visible; vertical-align: baseline; background-color: transparent; color: rgb(166, 19, 144);">nil</span><span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; overflow: visible; vertical-align: baseline; background-color: transparent; color: rgb(0, 34, 0);">]</span>;
6
<span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; overflow: visible; vertical-align: baseline; background-color: transparent; color: rgb(0, 34, 0);">[</span>operation start<span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; overflow: visible; vertical-align: baseline; background-color: transparent; color: rgb(0, 34, 0);">]</span>;
 
 

IMAGE REQUEST

<div class="devcodeoverflow" style="border: 1px solid rgb(204, 204, 204); vertical-align: baseline; background-color: transparent; margin: 1px !important; padding: 0px !important; outline: 0px !important; overflow: auto !important; float: none !important;"><table class="devcodearea  " width="100%"><tbody style="margin: 0px; padding: 0px; border: 0px; outline: 0px; overflow: visible; font-size: 12px; vertical-align: baseline; background-color: transparent;"><tr style="margin: 0px; padding: 0px; border: 0px; outline: 0px; overflow: visible; vertical-align: baseline; background-color: transparent;"><td class="devcodelines" width="1%" style="outline: 0px; overflow: visible; vertical-align: baseline; border-width: 0px 4px 0px 0px !important; border-right-style: solid !important; border-right-color: rgb(102, 238, 102) !important; padding: 0px 5px !important; margin: 0px !important; background-color: rgb(114, 158, 185) !important; font-family: 'courier new' !important; color: rgb(255, 255, 255) !important;">1</td><td class="devcodelinesarea" style="border-right-width: 0px; padding: 0px; margin: 0px; outline: 0px; overflow: visible; vertical-align: baseline; border-bottom-width: 0px !important; border-top-width: 0px !important; border-left-width: 0px !important;"><pre class="devcode devcodeline" name="code" style="white-space: pre-wrap; word-wrap: break-word; background-color: transparent; outline: 0px; overflow: visible; vertical-align: baseline; font-family: 'courier new' !important; border: 0px !important; padding: 0px 5px !important; margin-top: 0px !important; margin-bottom: 0px !important;">UIImageView <span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; overflow: visible; vertical-align: baseline; background-color: transparent; color: rgb(0, 34, 0);">*</span>imageView <span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; overflow: visible; vertical-align: baseline; background-color: transparent; color: rgb(0, 34, 0);">=</span> <span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; overflow: visible; vertical-align: baseline; background-color: transparent; color: rgb(0, 34, 0);">[</span><span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; overflow: visible; vertical-align: baseline; background-color: transparent; color: rgb(0, 34, 0);">[</span>UIImageView alloc<span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; overflow: visible; vertical-align: baseline; background-color: transparent; color: rgb(0, 34, 0);">]</span> initWithFrame<span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; overflow: visible; vertical-align: baseline; background-color: transparent; color: rgb(0, 34, 0);">:</span>CGRectMake<span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; overflow: visible; vertical-align: baseline; background-color: transparent; color: rgb(0, 34, 0);">(</span>0.0f, 0.0f, 100.0f, 100.0f<span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; overflow: visible; vertical-align: baseline; background-color: transparent; color: rgb(0, 34, 0);">)</span><span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; overflow: visible; vertical-align: baseline; background-color: transparent; color: rgb(0, 34, 0);">]</span>;
2
<span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; overflow: visible; vertical-align: baseline; background-color: transparent; color: rgb(0, 34, 0);">[</span>imageView setImageWithURL<span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; overflow: visible; vertical-align: baseline; background-color: transparent; color: rgb(0, 34, 0);">:</span><span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; overflow: visible; vertical-align: baseline; background-color: transparent; color: rgb(0, 34, 0);">[</span><span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; overflow: visible; vertical-align: baseline; background-color: transparent; color: rgb(64, 0, 128);">NSURL</span> URLWithString<span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; overflow: visible; vertical-align: baseline; background-color: transparent; color: rgb(0, 34, 0);">:</span><span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; overflow: visible; vertical-align: baseline; background-color: transparent; color: rgb(191, 29, 26);">@</span><span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; overflow: visible; vertical-align: baseline; background-color: transparent; color: rgb(191, 29, 26);">"http://i.imgur.com/r4uwx.jpg"</span><span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; overflow: visible; vertical-align: baseline; background-color: transparent; color: rgb(0, 34, 0);">]</span> placeholderImage<span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; overflow: visible; vertical-align: baseline; background-color: transparent; color: rgb(0, 34, 0);">:</span><span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; overflow: visible; vertical-align: baseline; background-color: transparent; color: rgb(0, 34, 0);">[</span>UIImage imageNamed<span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; overflow: visible; vertical-align: baseline; background-color: transparent; color: rgb(0, 34, 0);">:</span><span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; overflow: visible; vertical-align: baseline; background-color: transparent; color: rgb(191, 29, 26);">@</span><span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; overflow: visible; vertical-align: baseline; background-color: transparent; color: rgb(191, 29, 26);">"placeholder-avatar"</span><span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; overflow: visible; vertical-align: baseline; background-color: transparent; color: rgb(0, 34, 0);">]</span><span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; overflow: visible; vertical-align: baseline; background-color: transparent; color: rgb(0, 34, 0);">]</span>;
 
 

API CLIENT REQUEST

<div class="devcodeoverflow" style="border: 1px solid rgb(204, 204, 204); vertical-align: baseline; background-color: transparent; margin: 1px !important; padding: 0px !important; outline: 0px !important; overflow: auto !important; float: none !important;"><table class="devcodearea  " width="100%"><tbody style="margin: 0px; padding: 0px; border: 0px; outline: 0px; overflow: visible; font-size: 12px; vertical-align: baseline; background-color: transparent;"><tr style="margin: 0px; padding: 0px; border: 0px; outline: 0px; overflow: visible; vertical-align: baseline; background-color: transparent;"><td class="devcodelines" width="1%" style="outline: 0px; overflow: visible; vertical-align: baseline; border-width: 0px 4px 0px 0px !important; border-right-style: solid !important; border-right-color: rgb(102, 238, 102) !important; padding: 0px 5px !important; margin: 0px !important; background-color: rgb(114, 158, 185) !important; font-family: 'courier new' !important; color: rgb(255, 255, 255) !important;">1</td><td class="devcodelinesarea" style="border-right-width: 0px; padding: 0px; margin: 0px; outline: 0px; overflow: visible; vertical-align: baseline; border-bottom-width: 0px !important; border-top-width: 0px !important; border-left-width: 0px !important;"><pre class="devcode devcodeline" name="code" style="white-space: pre-wrap; word-wrap: break-word; background-color: transparent; outline: 0px; overflow: visible; vertical-align: baseline; font-family: 'courier new' !important; border: 0px !important; padding: 0px 5px !important; margin-top: 0px !important; margin-bottom: 0px !important;"><span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; overflow: visible; vertical-align: baseline; background-color: transparent; color: rgb(17, 116, 10);"><em>// AFGowallaAPIClient is a subclass of AFHTTPClient, which defines the base URL and default HTTP headers for NSURLRequests it creates</em></span>
2
<span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; overflow: visible; vertical-align: baseline; background-color: transparent; color: rgb(0, 34, 0);">[</span><span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; overflow: visible; vertical-align: baseline; background-color: transparent; color: rgb(0, 34, 0);">[</span>AFGowallaAPIClient sharedClient<span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; overflow: visible; vertical-align: baseline; background-color: transparent; color: rgb(0, 34, 0);">]</span> getPath<span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; overflow: visible; vertical-align: baseline; background-color: transparent; color: rgb(0, 34, 0);">:</span><span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; overflow: visible; vertical-align: baseline; background-color: transparent; color: rgb(191, 29, 26);">@</span><span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; overflow: visible; vertical-align: baseline; background-color: transparent; color: rgb(191, 29, 26);">"/spots/9223"</span> parameters<span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; overflow: visible; vertical-align: baseline; background-color: transparent; color: rgb(0, 34, 0);">:</span><span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; overflow: visible; vertical-align: baseline; background-color: transparent; color: rgb(166, 19, 144);">nil</span> success<span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; overflow: visible; vertical-align: baseline; background-color: transparent; color: rgb(0, 34, 0);">:^</span><span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; overflow: visible; vertical-align: baseline; background-color: transparent; color: rgb(0, 34, 0);">(</span>AFHTTPRequestOperation <span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; overflow: visible; vertical-align: baseline; background-color: transparent; color: rgb(0, 34, 0);">*</span>operation, <span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; overflow: visible; vertical-align: baseline; background-color: transparent; color: rgb(166, 19, 144);">id</span> responseObject<span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; overflow: visible; vertical-align: baseline; background-color: transparent; color: rgb(0, 34, 0);">)</span> <span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; overflow: visible; vertical-align: baseline; background-color: transparent; color: rgb(0, 34, 0);">{</span>
3
    NSLog<span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; overflow: visible; vertical-align: baseline; background-color: transparent; color: rgb(0, 34, 0);">(</span><span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; overflow: visible; vertical-align: baseline; background-color: transparent; color: rgb(191, 29, 26);">@</span><span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; overflow: visible; vertical-align: baseline; background-color: transparent; color: rgb(191, 29, 26);">"Name: %@"</span>, <span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; overflow: visible; vertical-align: baseline; background-color: transparent; color: rgb(0, 34, 0);">[</span>responseObject valueForKeyPath<span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; overflow: visible; vertical-align: baseline; background-color: transparent; color: rgb(0, 34, 0);">:</span><span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; overflow: visible; vertical-align: baseline; background-color: transparent; color: rgb(191, 29, 26);">@</span><span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; overflow: visible; vertical-align: baseline; background-color: transparent; color: rgb(191, 29, 26);">"name"</span><span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; overflow: visible; vertical-align: baseline; background-color: transparent; color: rgb(0, 34, 0);">]</span><span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; overflow: visible; vertical-align: baseline; background-color: transparent; color: rgb(0, 34, 0);">)</span>;
4
    NSLog<span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; overflow: visible; vertical-align: baseline; background-color: transparent; color: rgb(0, 34, 0);">(</span><span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; overflow: visible; vertical-align: baseline; background-color: transparent; color: rgb(191, 29, 26);">@</span><span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; overflow: visible; vertical-align: baseline; background-color: transparent; color: rgb(191, 29, 26);">"Address: %@"</span>, <span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; overflow: visible; vertical-align: baseline; background-color: transparent; color: rgb(0, 34, 0);">[</span>responseObject valueForKeyPath<span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; overflow: visible; vertical-align: baseline; background-color: transparent; color: rgb(0, 34, 0);">:</span><span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; overflow: visible; vertical-align: baseline; background-color: transparent; color: rgb(191, 29, 26);">@</span><span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; overflow: visible; vertical-align: baseline; background-color: transparent; color: rgb(191, 29, 26);">"address.street_address"</span><span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; overflow: visible; vertical-align: baseline; background-color: transparent; color: rgb(0, 34, 0);">]</span><span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; overflow: visible; vertical-align: baseline; background-color: transparent; color: rgb(0, 34, 0);">)</span>;
5
<span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; overflow: visible; vertical-align: baseline; background-color: transparent; color: rgb(0, 34, 0);">}</span> failure<span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; overflow: visible; vertical-align: baseline; background-color: transparent; color: rgb(0, 34, 0);">:</span><span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; overflow: visible; vertical-align: baseline; background-color: transparent; color: rgb(166, 19, 144);">nil</span><span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; overflow: visible; vertical-align: baseline; background-color: transparent; color: rgb(0, 34, 0);">]</span>;
 
 

FILE UPLOAD WITH PROGRESS CALLBACK

<div class="devcodeoverflow" style="border: 1px solid rgb(204, 204, 204); vertical-align: baseline; background-color: transparent; margin: 1px !important; padding: 0px !important; outline: 0px !important; overflow: auto !important; float: none !important;"><table class="devcodearea  " width="100%"><tbody style="margin: 0px; padding: 0px; border: 0px; outline: 0px; overflow: visible; font-size: 12px; vertical-align: baseline; background-color: transparent;"><tr style="margin: 0px; padding: 0px; border: 0px; outline: 0px; overflow: visible; vertical-align: baseline; background-color: transparent;"><td class="devcodelines" width="1%" style="outline: 0px; overflow: visible; vertical-align: baseline; border-width: 0px 4px 0px 0px !important; border-right-style: solid !important; border-right-color: rgb(102, 238, 102) !important; padding: 0px 5px !important; margin: 0px !important; background-color: rgb(114, 158, 185) !important; font-family: 'courier new' !important; color: rgb(255, 255, 255) !important;">01</td><td class="devcodelinesarea" style="border-right-width: 0px; padding: 0px; margin: 0px; outline: 0px; overflow: visible; vertical-align: baseline; border-bottom-width: 0px !important; border-top-width: 0px !important; border-left-width: 0px !important;"><pre class="devcode devcodeline" name="code" style="white-space: pre-wrap; word-wrap: break-word; background-color: transparent; outline: 0px; overflow: visible; vertical-align: baseline; font-family: 'courier new' !important; border: 0px !important; padding: 0px 5px !important; margin-top: 0px !important; margin-bottom: 0px !important;"><span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; overflow: visible; vertical-align: baseline; background-color: transparent; color: rgb(64, 0, 128);">NSURL</span> <span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; overflow: visible; vertical-align: baseline; background-color: transparent; color: rgb(0, 34, 0);">*</span>url <span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; overflow: visible; vertical-align: baseline; background-color: transparent; color: rgb(0, 34, 0);">=</span> <span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; overflow: visible; vertical-align: baseline; background-color: transparent; color: rgb(0, 34, 0);">[</span><span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; overflow: visible; vertical-align: baseline; background-color: transparent; color: rgb(64, 0, 128);">NSURL</span> URLWithString<span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; overflow: visible; vertical-align: baseline; background-color: transparent; color: rgb(0, 34, 0);">:</span><span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; overflow: visible; vertical-align: baseline; background-color: transparent; color: rgb(191, 29, 26);">@</span><span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; overflow: visible; vertical-align: baseline; background-color: transparent; color: rgb(191, 29, 26);">"http://api-base-url.com"</span><span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; overflow: visible; vertical-align: baseline; background-color: transparent; color: rgb(0, 34, 0);">]</span>;
02
AFHTTPClient <span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; overflow: visible; vertical-align: baseline; background-color: transparent; color: rgb(0, 34, 0);">*</span>httpClient <span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; overflow: visible; vertical-align: baseline; background-color: transparent; color: rgb(0, 34, 0);">=</span> <span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; overflow: visible; vertical-align: baseline; background-color: transparent; color: rgb(0, 34, 0);">[</span><span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; overflow: visible; vertical-align: baseline; background-color: transparent; color: rgb(0, 34, 0);">[</span>AFHTTPClient alloc<span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; overflow: visible; vertical-align: baseline; background-color: transparent; color: rgb(0, 34, 0);">]</span> initWithBaseURL<span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; overflow: visible; vertical-align: baseline; background-color: transparent; color: rgb(0, 34, 0);">:</span>url<span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; overflow: visible; vertical-align: baseline; background-color: transparent; color: rgb(0, 34, 0);">]</span>;
03
<span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; overflow: visible; vertical-align: baseline; background-color: transparent; color: rgb(64, 0, 128);">NSData</span> <span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; overflow: visible; vertical-align: baseline; background-color: transparent; color: rgb(0, 34, 0);">*</span>imageData <span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; overflow: visible; vertical-align: baseline; background-color: transparent; color: rgb(0, 34, 0);">=</span> UIImageJPEGRepresentation<span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; overflow: visible; vertical-align: baseline; background-color: transparent; color: rgb(0, 34, 0);">(</span><span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; overflow: visible; vertical-align: baseline; background-color: transparent; color: rgb(0, 34, 0);">[</span>UIImage imageNamed<span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; overflow: visible; vertical-align: baseline; background-color: transparent; color: rgb(0, 34, 0);">:</span><span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; overflow: visible; vertical-align: baseline; background-color: transparent; color: rgb(191, 29, 26);">@</span><span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; overflow: visible; vertical-align: baseline; background-color: transparent; color: rgb(191, 29, 26);">"avatar.jpg"</span><span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; overflow: visible; vertical-align: baseline; background-color: transparent; color: rgb(0, 34, 0);">]</span>, <span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; overflow: visible; vertical-align: baseline; background-color: transparent; color: rgb(36, 0, 217);">0.5</span><span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; overflow: visible; vertical-align: baseline; background-color: transparent; color: rgb(0, 34, 0);">)</span>;
04
<span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; overflow: visible; vertical-align: baseline; background-color: transparent; color: rgb(64, 0, 128);">NSMutableURLRequest</span> <span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; overflow: visible; vertical-align: baseline; background-color: transparent; color: rgb(0, 34, 0);">*</span>request <span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; overflow: visible; vertical-align: baseline; background-color: transparent; color: rgb(0, 34, 0);">=</span> <span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; overflow: visible; vertical-align: baseline; background-color: transparent; color: rgb(0, 34, 0);">[</span>httpClient multipartFormRequestWithMethod<span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; overflow: visible; vertical-align: baseline; background-color: transparent; color: rgb(0, 34, 0);">:</span><span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; overflow: visible; vertical-align: baseline; background-color: transparent; color: rgb(191, 29, 26);">@</span><span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; overflow: visible; vertical-align: baseline; background-color: transparent; color: rgb(191, 29, 26);">"POST"</span> path<span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; overflow: visible; vertical-align: baseline; background-color: transparent; color: rgb(0, 34, 0);">:</span><span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; overflow: visible; vertical-align: baseline; background-color: transparent; color: rgb(191, 29, 26);">@</span><span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; overflow: visible; vertical-align: baseline; background-color: transparent; color: rgb(191, 29, 26);">"/upload"</span> parameters<span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; overflow: visible; vertical-align: baseline; background-color: transparent; color: rgb(0, 34, 0);">:</span><span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; overflow: visible; vertical-align: baseline; background-color: transparent; color: rgb(166, 19, 144);">nil</span> constructingBodyWithBlock<span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; overflow: visible; vertical-align: baseline; background-color: transparent; color: rgb(0, 34, 0);">:</span> <span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; overflow: visible; vertical-align: baseline; background-color: transparent; color: rgb(0, 34, 0);">^</span><span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; overflow: visible; vertical-align: baseline; background-color: transparent; color: rgb(0, 34, 0);">(</span><span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; overflow: visible; vertical-align: baseline; background-color: transparent; color: rgb(166, 19, 144);">id</span> <AFMultipartFormData>formData<span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; overflow: visible; vertical-align: baseline; background-color: transparent; color: rgb(0, 34, 0);">)</span> <span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; overflow: visible; vertical-align: baseline; background-color: transparent; color: rgb(0, 34, 0);">{</span>
05
    <span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; overflow: visible; vertical-align: baseline; background-color: transparent; color: rgb(0, 34, 0);">[</span>formData appendPartWithFileData<span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; overflow: visible; vertical-align: baseline; background-color: transparent; color: rgb(0, 34, 0);">:</span>imageData name<span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; overflow: visible; vertical-align: baseline; background-color: transparent; color: rgb(0, 34, 0);">:</span><span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; overflow: visible; vertical-align: baseline; background-color: transparent; color: rgb(191, 29, 26);">@</span><span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; overflow: visible; vertical-align: baseline; background-color: transparent; color: rgb(191, 29, 26);">"avatar"</span> fileName<span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; overflow: visible; vertical-align: baseline; background-color: transparent; color: rgb(0, 34, 0);">:</span><span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; overflow: visible; vertical-align: baseline; background-color: transparent; color: rgb(191, 29, 26);">@</span><span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; overflow: visible; vertical-align: baseline; background-color: transparent; color: rgb(191, 29, 26);">"avatar.jpg"</span> mimeType<span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; overflow: visible; vertical-align: baseline; background-color: transparent; color: rgb(0, 34, 0);">:</span><span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; overflow: visible; vertical-align: baseline; background-color: transparent; color: rgb(191, 29, 26);">@</span><span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; overflow: visible; vertical-align: baseline; background-color: transparent; color: rgb(191, 29, 26);">"image/jpeg"</span><span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; overflow: visible; vertical-align: baseline; background-color: transparent; color: rgb(0, 34, 0);">]</span>;
06
<span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; overflow: visible; vertical-align: baseline; background-color: transparent; color: rgb(0, 34, 0);">}</span><span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; overflow: visible; vertical-align: baseline; background-color: transparent; color: rgb(0, 34, 0);">]</span>;
07
 
08
AFHTTPRequestOperation <span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; overflow: visible; vertical-align: baseline; background-color: transparent; color: rgb(0, 34, 0);">*</span>operation <span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; overflow: visible; vertical-align: baseline; background-color: transparent; color: rgb(0, 34, 0);">=</span> <span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; overflow: visible; vertical-align: baseline; background-color: transparent; color: rgb(0, 34, 0);">[</span><span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; overflow: visible; vertical-align: baseline; background-color: transparent; color: rgb(0, 34, 0);">[</span><span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; overflow: visible; vertical-align: baseline; background-color: transparent; color: rgb(0, 34, 0);">[</span>AFHTTPRequestOperation alloc<span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; overflow: visible; vertical-align: baseline; background-color: transparent; color: rgb(0, 34, 0);">]</span> initWithRequest<span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; overflow: visible; vertical-align: baseline; background-color: transparent; color: rgb(0, 34, 0);">:</span>request<span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; overflow: visible; vertical-align: baseline; background-color: transparent; color: rgb(0, 34, 0);">]</span> autorelease<span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; overflow: visible; vertical-align: baseline; background-color: transparent; color: rgb(0, 34, 0);">]</span>;
09
<span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; overflow: visible; vertical-align: baseline; background-color: transparent; color: rgb(0, 34, 0);">[</span>operation setUploadProgressBlock<span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; overflow: visible; vertical-align: baseline; background-color: transparent; color: rgb(0, 34, 0);">:^</span><span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; overflow: visible; vertical-align: baseline; background-color: transparent; color: rgb(0, 34, 0);">(</span>NSInteger bytesWritten, <span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; overflow: visible; vertical-align: baseline; background-color: transparent; color: rgb(166, 19, 144);">long</span> <span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; overflow: visible; vertical-align: baseline; background-color: transparent; color: rgb(166, 19, 144);">long</span> totalBytesWritten, <span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; overflow: visible; vertical-align: baseline; background-color: transparent; color: rgb(166, 19, 144);">long</span> <span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; overflow: visible; vertical-align: baseline; background-color: transparent; color: rgb(166, 19, 144);">long</span> totalBytesExpectedToWrite<span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; overflow: visible; vertical-align: baseline; background-color: transparent; color: rgb(0, 34, 0);">)</span> <span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; overflow: visible; vertical-align: baseline; background-color: transparent; color: rgb(0, 34, 0);">{</span>
10
    NSLog<span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; overflow: visible; vertical-align: baseline; background-color: transparent; color: rgb(0, 34, 0);">(</span><span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; overflow: visible; vertical-align: baseline; background-color: transparent; color: rgb(191, 29, 26);">@</span><span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; overflow: visible; vertical-align: baseline; background-color: transparent; color: rgb(191, 29, 26);">"Sent %lld of %lld bytes"</span>, totalBytesWritten, totalBytesExpectedToWrite<span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; overflow: visible; vertical-align: baseline; background-color: transparent; color: rgb(0, 34, 0);">)</span>;
11
<span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; overflow: visible; vertical-align: baseline; background-color: transparent; color: rgb(0, 34, 0);">}</span><span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; overflow: visible; vertical-align: baseline; background-color: transparent; color: rgb(0, 34, 0);">]</span>;
12
<span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; overflow: visible; vertical-align: baseline; background-color: transparent; color: rgb(0, 34, 0);">[</span>operation start<span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; overflow: visible; vertical-align: baseline; background-color: transparent; color: rgb(0, 34, 0);">]</span>;
 
 

STREAMING REQUEST

<div class="devcodeoverflow" style="border: 1px solid rgb(204, 204, 204); vertical-align: baseline; background-color: transparent; margin: 1px !important; padding: 0px !important; outline: 0px !important; overflow: auto !important; float: none !important;"><table class="devcodearea  " width="100%"><tbody style="margin: 0px; padding: 0px; border: 0px; outline: 0px; overflow: visible; font-size: 12px; vertical-align: baseline; background-color: transparent;"><tr style="margin: 0px; padding: 0px; border: 0px; outline: 0px; overflow: visible; vertical-align: baseline; background-color: transparent;"><td class="devcodelines" width="1%" style="outline: 0px; overflow: visible; vertical-align: baseline; border-width: 0px 4px 0px 0px !important; border-right-style: solid !important; border-right-color: rgb(102, 238, 102) !important; padding: 0px 5px !important; margin: 0px !important; background-color: rgb(114, 158, 185) !important; font-family: 'courier new' !important; color: rgb(255, 255, 255) !important;">1</td><td class="devcodelinesarea" style="border-right-width: 0px; padding: 0px; margin: 0px; outline: 0px; overflow: visible; vertical-align: baseline; border-bottom-width: 0px !important; border-top-width: 0px !important; border-left-width: 0px !important;"><pre class="devcode devcodeline" name="code" style="white-space: pre-wrap; word-wrap: break-word; background-color: transparent; outline: 0px; overflow: visible; vertical-align: baseline; font-family: 'courier new' !important; border: 0px !important; padding: 0px 5px !important; margin-top: 0px !important; margin-bottom: 0px !important;">NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"http://localhost:8080/encode"]];
2
 
3
AFHTTPRequestOperation *operation = [[[AFHTTPRequestOperation alloc] initWithRequest:request] autorelease];
4
operation.inputStream = [NSInputStream inputStreamWithFileAtPath:[[NSBundle mainBundle] pathForResource:@"large-image" ofType:@"tiff"]];
5
operation.outputStream = [NSOutputStream outputStreamToMemory];
6
[operation start];
 
 

你可能感兴趣的:(AFNetworking了解)