请求返回字符串的

<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>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值