Dispatch_async (Dispatch_get_global_queue (Dispatch_queue_priority_default,0), ^{nsmutableurlrequest*request =[[Nsmutableurlrequest alloc] Initwithurl:[nsurl urlwithstring:urlstr] CachePolicy: Nsurlrequestreloadignoringlocalcachedata Timeoutinterval:connectiont_timeout]; NSString*encodedstr =[Body stringbyaddingpercentescapesusingencoding:nsutf8stringencoding]; NSData*senddata =[Encodedstr datausingencoding:nsutf8stringencoding Allowlossyconversion:yes]; NSString*datalengthstr =[nsstring stringWithFormat:@"%lu", (unsignedLong) [senddata length]]; [Request Setvalue:datalengthstr Forhttpheaderfield:@"Content-length"]; [Request SetValue:@"application/x-www-form-urlencoded"Forhttpheaderfield:@"Content-type"]; [Request Sethttpmethod:@"POST"]; [Request Sethttpbody:senddata]; Self.connection= [Nsurlconnection connectionwithrequest:requestDelegate: Self]; });
This is a code executed in the main thread that has a problem with the execution result and cannot receive a network rollback.
Analysis to be Continued ...
Need to study why connection can't stop threads from ending! What can stop it?
IOS Nsurlconnection callback method Invalid parsing!