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