<code class="hljs objectivec has-numbering">AFHTTPSessionManager *manager =[AFHTTPSessionManager manager]; [manager GET:@<span class="hljs-string">"http://www.baidu.com"</span> parameters:<span class="hljs-literal">nil</span> success:^(NSURLSessionDataTask *task, <span class="hljs-keyword">id</span> responseObject) { <span class="hljs-built_in">NSString</span> *result = [[<span class="hljs-built_in">NSString</span> alloc]initWithData:responseObject encoding:NSUTF8StringEncoding]; <span class="hljs-built_in">NSLog</span>(@<span class="hljs-string">"%@"</span>,result); } failure:^(NSURLSessionDataTask *task, <span class="hljs-built_in">NSError</span> *error) { <span class="hljs-built_in">NSLog</span>(@<span class="hljs-string">"%@"</span>,error); }];</code>
<code class="hljs vbscript has-numbering"><span class="hljs-keyword">Error</span> Domain=NSCocoaErrorDomain Code=<span class="hljs-number">3840</span> <span class="hljs-string">"The operation couldn’t be completed. (Cocoa error 3840.)"</span> (JSON text did <span class="hljs-keyword">not</span> start <span class="hljs-keyword">with</span> <span class="hljs-built_in">array</span> <span class="hljs-keyword">or</span> object <span class="hljs-keyword">and</span> <span class="hljs-keyword">option</span> <span class="hljs-keyword">to</span> allow fragments <span class="hljs-keyword">not</span> <span class="hljs-keyword">set</span>.) UserInfo=<span class="hljs-number">0x8ea19a0</span> {NSDebugDescription=JSON text did <span class="hljs-keyword">not</span> start <span class="hljs-keyword">with</span> <span class="hljs-built_in">array</span> <span class="hljs-keyword">or</span> object <span class="hljs-keyword">and</span> <span class="hljs-keyword">option</span> <span class="hljs-keyword">to</span> allow fragments <span class="hljs-keyword">not</span> <span class="hljs-keyword">set</span>.}</code>
<code class="hljs objectivec has-numbering"> AFHTTPSessionManager *manager =[AFHTTPSessionManager manager]; manager<span class="hljs-variable">.responseSerializer</span> = [AFHTTPResponseSerializer serializer]; [manager GET:@<span class="hljs-string">"http://www.baidu.com"</span> parameters:<span class="hljs-literal">nil</span> success:^(NSURLSessionDataTask *task, <span class="hljs-keyword">id</span> responseObject) { <span class="hljs-built_in">NSString</span> *result = [[<span class="hljs-built_in">NSString</span> alloc]initWithData:responseObject encoding:NSUTF8StringEncoding]; <span class="hljs-built_in">NSLog</span>(@<span class="hljs-string">"%@"</span>,result); } failure:^(NSURLSessionDataTask *task, <span class="hljs-built_in">NSError</span> *error) { <span class="hljs-built_in">NSLog</span>(@<span class="hljs-string">"%@"</span>,error); }];</code>