Afnetwork 2.0 in the request times wrong code=-1016 and 3840

Source: Internet
Author: User

Occurs when a network request is made-1016 because only support

Text/json,application/json,text/javascript

You can add text/html

Once and for all, the method is

AFURLResponseSerialization.h

Inside search

Self.acceptablecontenttypes

and add it in there.

@ "text/html", @ "Text/plain"

This will solve the 1016 error.

But then comes a 3840 error.

Error Domain=nscocoaerrordomain code=3840 "The operation couldn ' t be completed. (Cocoa error 3840.) " (JSON text did not start with an array or object and option to allow fragments not set.) userinfo=0x9152780 {Nsdebugdescription=json text did not ' start with array ' or ' object ' and ' option to ' Allow fragments ' not set. }

You will find that this error occurs

What to do?

Add the following statement to solve the problem

Manger.requestserializer = [Afhttprequestserializerserializer];

Manger.responseserializer = [Afhttpresponseserializerserializer];

Success, Success! But there's a coding problem with the new problem. If the server returns a, you receive a <61>

How can this be done?

When you use your browser to request it, you find the response header content-type:text/html;charset=utf-8.

But the afnetwork request is Content-type:text/plain;charset=iso-8859-1 is this inconsistent?

Why is PC browser access inconsistent with afnetwork access? Don't know what the situation is?

and then found to add the following two sentences can also not be modified AFURLResponseSerialization.h inside of the thing

Manger.requestserializer = [Afhttprequestserializerserializer];

Manger.responseserializer = [Afhttpresponseserializerserializer];

Put the received

Responseobject Convert the code, it's OK.

NSData *doubi = Responseobject;

NSString *shabi = [[nsstring alloc]initwithdata:d Oubi encoding : nsutf8stringencoding ];

Afnetwork 2.0 in the request times wrong code=-1016 and 3840

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.