nsurlconnectiondelegate

NSMutableURLRequest “The request timed out” issue . .

筅森魡賤 提交于 2019-12-06 06:29:01
问题 I am trying to download data in my application by using the following code NSURL *url = [NSURL URLWithString:@"my download url string"]; NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url cachePolicy:NSURLRequestReloadIgnoringCacheData timeoutInterval:60.f]; NSURLConnection * connection = [NSURLConnection connectionWithRequest:request delegate:self]; [connection start]; but the problem is some times i am getting the following error Error Domain=NSURLErrorDomain Code=-1001

Asynchronous NSURLConnection on separate thread fails to call delegate methods

て烟熏妆下的殇ゞ 提交于 2019-12-04 22:20:56
问题 I am running a NSURLConnection on a separate thread (I am aware that it is asynchronous and works when running on the main thread), but it is not making delegate calls even when I pass the parent thread as the delegate. Does anyone know how to do this? Code: -(void)startConnectionWithUrlPath:(NSString*)URLpath { //initiates the download connection - setup NSURL *myURL = [[NSURL alloc] initWithString:URLpath]; myURLRequest = [NSMutableURLRequest requestWithURL:myURL cachePolicy

Twitter iOS Streaming API: no data being received

寵の児 提交于 2019-12-04 16:27:58
I'm trying to modify Apple's sample code for using the Twitter API so that I can use the streaming API to filter tweets. I am attempting to implement the method suggested in response to this question: Does TWRequest work for the twitter streaming api? I have created the signed NSURLRequest and NSURLConnection objects as suggested, and set the delegate for the connection object. A valid twitter account is selected and used to sign the url. The problem is that the delegates connection:didReceiveData: method is never being called. Here's my code: @implementation Twitter -(id)init{ if (self=[super

NSURLConnectionDownloadDelegate file issue

心不动则不痛 提交于 2019-12-03 17:05:07
问题 Now that 5.0 is launched and we can discuss it without breaching Apple's NDA, I have an issue with the new version of NSURLConnection. This has a new delegate, NSURLConnectionDownloadDelegate with two key methods. connection:didWriteData:totalBytesWritten:expectedTotalBytes: is invoked repeatedly while the file download is progressing connectionDidFinishDownloading:destinationURL: is called once when the download is complete. The downloaded file should then be at destinationURL (at least for

Set the progress to UIProgressView when upload with NSURLConnection

馋奶兔 提交于 2019-12-01 22:03:39
问题 I'm trying to refresh the progress bar in an UIProgressView for an upload request with NSURLConnection . The goal is to refresh the progress bar while uploading a picture. After several searches, I managed to use the didSendBodyData of my connection delegate to check the progress like this : - (void)connection:(NSURLConnection *)connection didSendBodyData:(NSInteger)bytesWritten totalBytesWritten:(NSInteger)totalBytesWritten totalBytesExpectedToWrite:(NSInteger)totalBytesExpectedToWrite { if(

iOS4 Implementation of -[NSURLConnection sendAsynchronousRequest:queue:completionHandler:]?

被刻印的时光 ゝ 提交于 2019-11-30 15:46:40
How can I implement -[NSURLConnection sendAsynchronousRequest:queue:completionHandler:] for iOS < 5? #if __IPHONE_OS_VERSION_MIN_REQUIRED < __IPHONE_5_0 #import <objc/runtime.h> #import "NSURLConnection+iOS4.h" // Dynamically add -[NSURLConnection sendAsynchronousRequest:queue:completionHandler:]. void *sendAsynchronousRequest4(id self, SEL _cmd, NSURLRequest *request, NSOperationQueue *queue, void (^handler)(NSURLResponse*, NSData*, NSError*)); void *sendAsynchronousRequest4(id self, SEL _cmd, NSURLRequest *request, NSOperationQueue *queue, void (^handler)(NSURLResponse*, NSData*, NSError*))

iphone: secure restfull server \"The certificate for this server is invalid

耗尽温柔 提交于 2019-11-29 04:36:56
I am trying to consume secure restful service which gives error Error = Error Domain=NSURLErrorDomain Code=-1202 "The certificate for this server is invalid. You might be connecting to a server that is pretending to be “xxx.xxx.xxx.xxx” which could put your confidential information at risk." working on xCode 4.2, where is the mistake or any step missing. using following code RegisterUser.f @interface RegisterUser : UIViewController<UITextFieldDelegate, UIScrollViewDelegate, NSURLConnectionDelegate> RegisterUser.m - (IBAction)SubmitBtnAction:(id)sender { NSURL *url = [NSURL URLWithString:@

how to unit test a NSURLConnection Delegate?

Deadly 提交于 2019-11-29 02:55:05
问题 How can I unit test my NSURLConnection delegate? I made a ConnectionDelegate class which conforms to different protocols to serve data from the web to different ViewControllers. Before I get too far I want to start writing my unit tests. But I don't know how to test them as a unit without the internet connection. I would like also what I should do to treat the asynchronous callbacks. 回答1: This is similar to Jon's response, couldn't fit it into a comment, though. The first step is to make sure

NSUrlConnectionDelegate - Getting http status codes

◇◆丶佛笑我妖孽 提交于 2019-11-28 21:06:23
in iOS, how can I receive the http status code (404,500 200 etc) for a response from a web server. I am assuming it's in the NSUrlConnectionDelegate. Objective-C or Monotouch .NET answer ok. Yes, you can get status code in delegate method -didRecieveResponse: - (void) connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response{ NSHTTPURLResponse* httpResponse = (NSHTTPURLResponse*)response; int code = [httpResponse statusCode]; } Manuel NSHTTPURLResponse* urlResponse = nil; NSError *error = nil; responseData = [NSURLConnection sendSynchronousRequest:request

NSUrlConnectionDelegate - Getting http status codes

喜欢而已 提交于 2019-11-27 20:51:28
问题 in iOS, how can I receive the http status code (404,500 200 etc) for a response from a web server. I am assuming it's in the NSUrlConnectionDelegate. Objective-C or Monotouch .NET answer ok. 回答1: Yes, you can get status code in delegate method -didRecieveResponse: - (void) connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response{ NSHTTPURLResponse* httpResponse = (NSHTTPURLResponse*)response; int code = [httpResponse statusCode]; } 回答2: NSHTTPURLResponse*