Directory
1,[NSString containsstring:] in IOS7 will crash (nonsense) 2, when using afnetworking, if you want to see what the specific link is sent please break point here
3, encountered a nasty server, return data when the first to tell you error, and then put the error message inside the body ....
1,[NSString containsstring:] in IOS7 will crash (nonsense)
Solution: The online change is generally in the nsstring with a containsstring function, but this can not be judged according to the version number of calls (where the word will lead to a dead loop, you can try to play ~), so you may consider a separate list.
[Self containsstring:string andsubstring:@ "]-(BOOL) containsstring: (NSString *) ostring andsubstring: (NSString *) subString { if ([[Uidevice Currentdevice] Systemversion].floatvalue >= 8.0) { return [ostring containsstring : SubString]; } else if ([ostring rangeofstring:substring].location! = nsnotfound) { return YES; } return NO;}
2, when using afnetworking, if you want to see what the specific link is sent here, break the point here:
AFURLREQUESTSERIALIZATION.M 331 Lines
-(Nsmutableurlrequest *) Requestwithmethod: (NSString *) method URLString: (NSString*) urlstring parameters: (ID) Parameters Error: (Nserror*__autoreleasing *) error{Nsparameterassert (method); Nsparameterassert (urlstring); Nsurl*url =[Nsurl urlwithstring:urlstring]; Nsparameterassert (URL); Nsmutableurlrequest*mutablerequest =[[Nsmutableurlrequest alloc] initwithurl:url]; Mutablerequest.httpmethod=method; for(NSString *keypathinchafhttprequestserializerobservedkeypaths ()) { if([self.mutableobservedchangedkeypaths Containsobject:keypath]) {[Mutablerequest setvalue:[self valueForKe Ypath:keypath] Forkey:keypath]; }} mutablerequest=[[Self requestbyserializingrequest:mutablerequest withparameters:parameters error:error] mutableCopy]; returnmutablerequest;}
If you can't find it, query mutablerequest just fine. In addition, if it is a post type, break off before 331 lines return, enter PO parameters to check the parameters you passed. Unfortunately, this time the parameters have not been encode yo ~
3, encountered a nasty server, return data when the first to tell you error, and then put the error message inside the body ....
Afnetworking itself will not help you to parse. There is no way you can only change afnetworking ...
Try to use Afhttprequestoperation *operation to parse this variable in error
Our project was changed in this way: BCJSONOBJECTREQUEST.M
- (void) SendRequest {_tag= STag + +; [Self buildparams]; //parsing void(^success) (Afhttprequestoperation *operation,IDResponseobject) = ^ (Afhttprequestoperation *operation,IDresponseobject) {Dispatch_async (Dispatch_get_global_queue (Dispatch_queue_priority_default,0), ^{nserror*Erro; IDresult = [Self parseresponse:responseobject error:&Erro]; Dispatch_async (Dispatch_get_main_queue (),^{ //callback in the main thread if(Erro! =Nil) {[Self Inerjsonresultfailed:erro]; }Else{[Self inerjsonresultsuccess:result]; } }); }); }; void(^failure) (Afhttprequestoperation *operation, nserror *error) = ^ (Afhttprequestoperation *operation, NSError *error) {Dispatch_async (Dispatch_get_global_queue (Dispatch_queue_priority_default,0), ^{ IDErro =[self parseerro:error]; Dispatch_async (Dispatch_get_main_queue (),^{nserror*Parseerro; IDresult = [Self parseResponse:operation.responseObject error:&Parseerro]; if(Result! = Nil && Operation.responseobject! =Nil) { if([Result iskindofclass:nserror.class]) {[Self inerjsonresultfailed:result]; } Else{[Self inerjsonresultsuccess:result]; } } Else { //callback in the main thread[self Inerjsonresultfailed:erro]; } }); }); }; //Call RequestBchttpfacade *manager =[Bchttpfacade Sharefacade]; Switch(self.requestmethod) { CaseGet:self.requestOperation= [Manager Get:_url parameters:self.paramssuccess:success Failure:failure]; Break; CasePost:if(Self.mutipartblock) {[Manager Post:_url parameters:self.paramsconstructingBodyWithBlock:self.mutipartBlock success:success Failure:failure]; }Else{self.requestoperation= [Manager Post:_url parameters:self.paramssuccess:success Failure:failure]; } Break; default: LogError (@"Unsupport Method:requestmethod =%d,url =%@", Self.requestmethod,self.url); Break; }}
"IOS" some Bugs/tips records