[英]JSON parse error: Error Domain=NSCocoaErrorDomain Code=3840 "The operation couldn’t be completed. (Cocoa error 3840.)
I am using sendAsynchronousRequest request to server for getting data from it. 我正在使用sendAsynchronousRequest请求到服务器以从中获取数据。 When i check web service in browser its working fine and able to get the response.
当我在浏览器中检查Web服务时,它的工作正常,并且能够获得响应。 But when i sending request from Xcode i am not able to get the response in Xcode.
但是当我从Xcode发送请求时,我无法在Xcode中获得响应。 I am using the below code for sending response.
我正在使用以下代码发送响应。
NSString *strurl=[NSString stringWithFormat:@"%@/rest_stores/storeCategoryListByStoreId/%@.json",baseurl,[[NSUserDefaults standardUserDefaults] valueForKey:@"storeid"]];
NSURL *url = [NSURL URLWithString:strurl];
NSURLRequest *req = [NSURLRequest requestWithURL:url];
[NSURLConnection sendAsynchronousRequest:req queue:[NSOperationQueue mainQueue] completionHandler:^(NSURLResponse *response, NSData *data, NSError *error)
{
NSString *responseString = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
NSError *jsonError;
NSData *trimmedData = [responseString dataUsingEncoding:NSUTF8StringEncoding];
NSDictionary *json = [NSJSONSerialization JSONObjectWithData:trimmedData options:NSJSONReadingAllowFragments error:&jsonError];
if (jsonError)
{
NSLog(@"JSON parse error: %@", jsonError);
[HUD hide:YES];
return;
}
}];
And request taking too much time for to load response and after that I am getting response data null. 并且请求花费太多时间来加载响应,然后我得到响应数据为null。 And the error which Xcode shows me.
Xcode显示的错误。
JSON parse error: Error Domain=NSCocoaErrorDomain Code=3840 "The operation couldn’t be completed. (Cocoa error 3840.)" (No value.) UserInfo=0x112e4d390 {NSDebugDescription=No value.}
Till Yesterday it was working fine. 直到昨天,一切正常。 But When i start it today.
但是,当我今天开始。 I am facing this wired issue.
我正在面对这个有线问题。 I am not able to get response of any web service of my project but all are working fine in browser.
我无法获得我项目的任何Web服务的响应,但是在浏览器中都可以正常工作。
I solved my problem, May be it's Xcode issue. 我解决了我的问题,可能是Xcode问题。 I just remove projects from Organizer and reset simulator.
我只是从管理器中删除项目并重置模拟器。 Now it's working fine as it is.
现在它可以正常工作了。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.