标签: sendasynchronousrequest

APNS:错误域= NSCocoaErrorDomain代码= 3840

我在服务器上注册设备数据,以获得推送通知.这是代码,

[NSURLConnection sendAsynchronousRequest: request
                                           queue: _postQueue
                               completionHandler: ^(NSURLResponse *response, NSData *responseData, NSError *connectionError) {
                                   if (connectionError) {
                                       //
                                   } else {
                                      NSError *error = nil;
        NSDictionary *dictionary = [NSJSONSerialization JSONObjectWithData: responseData options: NSJSONReadingMutableContainers error: &error];
                                   }
                               }];
Run Code Online (Sandbox Code Playgroud)

我得到的错误是

Error Domain=NSCocoaErrorDomain Code=3840 "The operation couldn’t be completed. (Cocoa error 3840.)" (JSON text did not start with array or object and option to allow fragments not set.) UserInfo=0x17057f60 {NSDebugDescription=JSON text did not start with array or object and option to allow fragments …
Run Code Online (Sandbox Code Playgroud)

json apple-push-notifications ios sendasynchronousrequest

2
推荐指数
1
解决办法
2万
查看次数

在快速启动屏幕期间使用网络服务

我是 ios swift 的新手,

如何在闪屏期间从网络服务获取数据,

换句话说,我想让闪屏仍然出现,直到应用程序完成获取数据。

我尝试将 NSURLConnection.sendAsynchronousRequest函数放入 appdelegate 但启动画面不等待 sendAsynchronousRequest 完成

splash-screen nsurlconnection sendasynchronousrequest swift ios8

2
推荐指数
1
解决办法
5220
查看次数

在更新UI之前出现NSURLConnection sendAsynchronousRequest completionHandler日志

我有这个代码将json字符串发送到服务器

[NSURLConnection
 sendAsynchronousRequest:req
 queue:[[NSOperationQueue alloc] init]
 completionHandler:^(NSURLResponse *response,
                     NSData *data,
                     NSError *error)
 {

     if ([data length] >0 && error == nil)
     {

         NSLog(@"Done");

     }
     else if ([data length] == 0 && error == nil)
     {
         NSLog(@"Nothing was downloaded.");
         self.resultLabel.text=@"Done!";
         self.view.userInteractionEnabled = TRUE;
     }
     else if (error != nil){
         NSLog(@"Error = %@", error);
     }


 }];
Run Code Online (Sandbox Code Playgroud)

异步请求完成后,日志在完成后几乎立即显示.但是,这段代码:

self.resultLabel.text=@"Done!";
self.view.userInteractionEnabled = TRUE;
Run Code Online (Sandbox Code Playgroud)

在UI中显示10秒钟.有人知道为什么会这样吗?

objective-c ios sendasynchronousrequest

1
推荐指数
1
解决办法
941
查看次数

使用NSURLConnection忽略SSL证书错误

我正在使用[NSURLConnection sendAsynchronousRequest:request queue:[NSOperationQueue mainQueue] completionHandler:^(NSURLResponse *response, NSData *data, NSError *error)]从Web服务提取数据,但Web服务器具有自行颁发的证书,导致出现此错误:

SSL错误

显示错误:

NSAlert *a = [NSAlert alertWithError:error];
[a runModal];
Run Code Online (Sandbox Code Playgroud)

有没有办法忽略这个错误并继续?

cocoa nsurlconnection sendasynchronousrequest

1
推荐指数
1
解决办法
5587
查看次数

异步请求iOS 6的NSURLConnection状态代码

目前使用来自NSURLConnection的sendAsynchronous来发布和获取请求,但无法获取响应中的状态代码.大多数帖子都建议使用NSURLConnection及其委托方法,我理解它们也是异步的.

我不明白委托如何将信息发送回调用方法(最终需要数据的方法).sendAsynchronous方法有一个我现在正在使用的回调.

我是新来的,谢谢你的帮助.

cocoa-touch http-status-code-401 nsurlconnectiondelegate sendasynchronousrequest ios6

1
推荐指数
1
解决办法
3107
查看次数

使用 Spring Boot 的异步服务

我正在尝试使用 springboot 运行基本的异步服务。
调用请求时出现异常。不知道为什么会这样,我使用了 oracle 网站和 jersey 网站上的所有说明和代码片段。我这里有什么遗漏吗?如果您需要更多信息,请询问我,我会相应地更新问题。谢谢你。

org.springframework.beans.BeanInstantiationException: Failed to instantiate [javax.ws.rs.container.AsyncResponse]: Specified class is an interface
at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:101)
at org.springframework.web.method.annotation.ModelAttributeMethodProcessor.createAttribute(ModelAttributeMethodProcessor.java:137)
at org.springframework.web.servlet.mvc.method.annotation.ServletModelAttributeMethodProcessor.createAttribute(ServletModelAttributeMethodProcessor.java:80)
at org.springframework.web.method.annotation.ModelAttributeMethodProcessor.resolveArgument(ModelAttributeMethodProcessor.java:106)
at org.springframework.web.method.support.HandlerMethodArgumentResolverComposite.resolveArgument(HandlerMethodArgumentResolverComposite.java:78)
at org.springframework.web.method.support.InvocableHandlerMethod.getMethodArgumentValues(InvocableHandlerMethod.java:162)
at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:129)
at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:110)
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:775)
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:705)
at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:85)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:959)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:893)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:967)
at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:858)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:622)
at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:843)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:291)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:77)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:85)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) …
Run Code Online (Sandbox Code Playgroud)

java jax-rs sendasynchronousrequest jersey-2.0 spring-boot

1
推荐指数
1
解决办法
4349
查看次数