简体   繁体   English

JSON解析错误:错误域= NSCocoaErrorDomain代码= 3840“该操作无法完成。(可可错误3840。)

[英]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.

相关问题 错误域= NSCocoaErrorDomain代码= 3840“操作无法完成。(可可错误3840.) - Error Domain = NSCocoaErrorDomain Code=3840 "The operation couldn’t be completed. (Cocoa error 3840.) 如何解决错误:操作无法完成。 (可可错误3840。)json iOS? - How to resolve error:the operation couldn’t be completed. (cocoa error 3840.) json iOS? 错误:错误域= NSCocoaErrorDomain代码= 3840“该操作无法完成。 - Error:Error Domain=NSCocoaErrorDomain Code=3840 "The operation couldn’t be completed. iOS - Twitter连接问题:“操作无法完成。 (可可错误3840.)“ - iOS - Twitter Connectivity Issue: “The operation couldn’t be completed. (Cocoa error 3840.)” 该操作无法完成。 (可可错误3840。)”(在字符16周围的对象中没有键值。) - The operation couldn’t be completed. (Cocoa error 3840.)" (No value for key in object around character 16.) 可可错误3840无法完成操作 - Cocoa error 3840 The operation couldn’t be completed 错误域=NSCocoaErrorDomain 代码=3840“无法在 iOS 中使用 AFNetworking 完成操作 - Error Domain=NSCocoaErrorDomain Code=3840 "The operation couldn’t be completed in iOS using AFNetworking Error Domain = NSCocoaErrorDomain Code = 3840“无法使用AFNetworking完成操作 - Error Domain=NSCocoaErrorDomain Code=3840 "The operation couldn’t be completed using AFNetworking Domain = NSCocoaErrorDomain代码= 3840“操作无法完成 - Domain=NSCocoaErrorDomain Code=3840 "The operation couldn’t be completed checkResourceIsReachableAndReturnError总是返回Domain = NSCocoaErrorDomain Code = 4“操作无法完成。 (可可错误4。)” - checkResourceIsReachableAndReturnError always return Domain=NSCocoaErrorDomain Code=4 “The operation couldn’t be completed. (Cocoa error 4.)”
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM