草庐IT

sendasynchronousrequest

全部标签

objective-c - 应用程序被 iOS 杀死后,NSURLConnection sendSynchronousRequest/sendAsynchronousRequest 失败

我的应用程序中的所有服务器连接都以相同的方式进行:dispatch_async到第二个线程。发送同步请求主线程上的失败/成功block。以下不是完整代码,只是概念:dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT,0),^{NSURL*url=[NSURLURLWithString:@"someURL"];NSMutableURLRequest*request=[NSMutableURLRequestrequestWithURL:url];NSURLResponse*response=nil

ios - 弃用 : 'sendAsynchronousRequest:queue:completionHandler:' in iOS9

我有自己的类来进行http调用,但现在在iOS9中不推荐使用此方法:[NSURLConnetionsendAsynchronousRequest:queue:completionHandler:]我正在尝试测试新的[NSURLSessiondataTaskWithRequest:completionHandler:]但是Xcode报错,因为它没有找到这个方法。带有弃用行的Xcode编译器警告:'sendAsynchronousRequest:queue:completionHandler:'isdeprecated:firstdeprecatediniOS9.0-Use[NSURLSe

ios - 弃用 : 'sendAsynchronousRequest:queue:completionHandler:' in iOS9

我有自己的类来进行http调用,但现在在iOS9中不推荐使用此方法:[NSURLConnetionsendAsynchronousRequest:queue:completionHandler:]我正在尝试测试新的[NSURLSessiondataTaskWithRequest:completionHandler:]但是Xcode报错,因为它没有找到这个方法。带有弃用行的Xcode编译器警告:'sendAsynchronousRequest:queue:completionHandler:'isdeprecated:firstdeprecatediniOS9.0-Use[NSURLSe

ios - 使用带有委托(delegate)回调的 NSURLConnection 和 sendAsynchronousRequest :queue:completionHandler:? 之间有区别吗

我想了解使用–initWithRequest:delegate:和委托(delegate)方法和+sendAsynchronousRequest:queue:completionHandler:之间的区别。是否存在基于请求数量或任何其他标准的一些性能差异? 最佳答案 sendAsynchronousRequest:queue:completionHandler调用起来更容易。initWithRequest:delegate让您可以更好地控制缓存、重定向、下载大量或增量数据、取消请求等。

iOS NSURLConnection (sendAsynchronousRequest :) too much cache

我的应用程序中有几个内存泄漏(不!请参阅更新1),它们都归结为异步URLRequest。下面的代码给了我一个内存泄漏,似乎“数据”从未被释放(下面的代码在逻辑上没有在我的应用程序中使用,因为它是一个完全无用的无限循环,我只是写它来显示内存泄漏。这个使使用的RAM在不到一秒内从5MB增加到20MB。我的网速确实符合这个[仅作记录]):-(void)start{NSOperationQueue*oQC=[[NSOperationQueuealloc]init];NSLog(@"a");[NSURLConnectionsendAsynchronousRequest:[NSURLRequest

ios - NSURL Connection sendAsynchronousRequest 如何保存响应?

.h@property(strong)NSString*reply;我有以下方法:.m@synthesizereply;-(void)send{[NSURLConnectionsendAsynchronousRequest:[selfrequest]queue:[[NSOperationQueuealloc]init]completionHandler:^(NSURLResponse*response,NSData*data,NSError*error){if(error){//NSLog(@"Error,%@",[errorlocalizedDescription]);[selfse

ios - 创建多个 NSURLConnections 并使用 sendAsynchronousRequest :queue:completionHandler: iOS 5 method

我在设置与sendAsynchronousRequest:queue:completionHandler:方法(NSURLConnection类)相关的正确配置时遇到了一些困难。我的场景如下:我设置了一个单例类来管理不同的NSURLConnection。此单例实例有一个NSOperationQueue(称为downloadQueue),它向Web服务器发出请求并检索字符串路径(1)。完成后,该路径用于在Web服务器(2)中下载文件。最后,当文件已正确下载后,我需要更新UI(3)。我只计算出第一个请求:我可以通过它下载路径的请求。你能建议我执行其他两个步骤的方法吗?这里有几个问题:下载队

ios - 带有 sendAsynchronousRequest Objective-C 的 NSURLConnection 进度条

我正在使用以下方法下载一堆较大的zip文件。这可能需要一些时间,所以我想显示一个进度条。我研究了如何处理NSURLConnection的委托(delegate)方法,这看起来很简单,但是我想用“sendAsynchronousRequest”实现同样的事情。如何获取下载时下载的字节数以及预期的总字节数,以便显示进度条?我了解,如果我以我正在执行的方式开始下载,我将无法使用委托(delegate)方法。//Beginthedownloadprocess-(void)beginDownload:(NSMutableArray*)requests{//Nowfireoffabunchofre

ios - iOS 9 中弃用了 sendAsynchronousRequest

我正在尝试将我的代码从Swift1.2更改为Swift2.0,但我在“sendAsynchronousRequest”方面遇到了一些问题,因为它总是显示警告,因为它已被弃用。我尝试使用这篇文章中的另一种解决方案:Cannotinvoke'sendAsynchronousRequest'inSwift2withanargumentlist但它仍然不起作用,我再次收到相同的警告。我必须在我的代码中更改什么才能解决此警告?警告如下:sendAsynchronousRequest在iOS9中被弃用,使用dataTaskWithRequest:completionHandler这是我的代码:fu

ios - Segue 抛出 NSInternalInconsistencyException,使用 NSURLConnection sendAsynchronousRequest

所以我一直在尝试为网站创建一个应用程序,并且“登录”页面正常工作,除非它不会转换到下一个View。我认为这是导致问题的代码:NSOperationQueue*queue=[[NSOperationQueuealloc]init];[NSURLConnectionsendAsynchronousRequest:requestqueue:queuecompletionHandler:^(NSURLResponse*response,NSData*data,NSError*error){NSString*str=[[NSStringalloc]initWithData:dataencodin