nsurlconnection

error handling with NSURLConnection sendSynchronousRequest

六眼飞鱼酱① 提交于 2019-11-27 18:50:22
how can i do better error handling with NSURLConnection sendSynchronousRequest? is there any way i can implement - (void)connection:(NSURLConnection *)aConn didFailWithError:(NSError *)error i have a nsoperation queue which is getting data in background thats why i have sync request. and if i have to implement async request then how can i wait for request to get complete. because that method can't proceed without data. Ben Gottlieb -sendSynchronousRequest:returningResponse:error: gives you a way to get an error right there in the method itself. That last argument is really (NSError **) error;

NSURLConnection/NSURLRequest gzip support

被刻印的时光 ゝ 提交于 2019-11-27 18:21:05
Does anyone knows if NSURLConnection/NSURLRequest have support for gzip requests. If does, can you provide more information? ax. although it does not seem to be documented , there is evidence that NSURLConnection does have transparent gzip support. meaning that if the server supports gzip encoding, and your request has an Accept-Encoding header containing gzip *, the server will send a gzipped response, which NSURLConnection will automatically decode. * NSURLRequest might add that header by default. if not, you have to add it manually like so: [urlReq setValue:@"gzip" forHTTPHeaderField:@

NSURLConnection delegate methods are not called

元气小坏坏 提交于 2019-11-27 18:05:42
I am trying to create a simple NSURLConnection to communicate with a server using a GET request. Connection works well, but delegates methods of NSURLConnection are never called.. Here is what am doing: NSString *post = [NSString stringWithFormat:@"key1=%@&key2=%@&key3=%f&key4=%@", val1, val4, val3, val4]; NSMutableURLRequest *request = [[[NSMutableURLRequest alloc] init] autorelease] ; [request setURL:[NSURL URLWithString:[NSString stringWithFormat:@"http://www.domain.com/demo/name/file.php?%@", post]]]; NSURLConnection *connection = [[NSURLConnection alloc] initWithRequest:request delegate

How to download a large file with the iPhone SDK and avoid memory usage issues?

生来就可爱ヽ(ⅴ<●) 提交于 2019-11-27 17:28:05
I'm using the NSURLConnection class to download a large file in my iPhone application, but it crashes every so often because it's using too much memory. I'm doing the usual NSURLConnection usage, to append the received data to a NSMutableData object. - (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data { [self.fileData appendData:data]; } Then after I finish downloading the whole file, I save it to a local temporary file, and read it as a mapped file like this: - (void)connectionDidFinishLoading:(NSURLConnection *)connection { // save the downloaded data into a

Asynchronous request to the server from background thread

萝らか妹 提交于 2019-11-27 16:58:21
I've got the problem when I tried to do asynchronous requests to server from background thread. I've never got results of those requests. Simple example which shows the problem: @protocol AsyncImgRequestDelegate -(void) imageDownloadDidFinish:(UIImage*) img; @end @interface AsyncImgRequest : NSObject { NSMutableData* receivedData; id<AsyncImgRequestDelegate> delegate; } @property (nonatomic,retain) id<AsyncImgRequestDelegate> delegate; -(void) downloadImage:(NSString*) url ; @end @implementation AsyncImgRequest -(void) downloadImage:(NSString*) url { NSURLRequest *theRequest=[NSURLRequest

What are alternatives to NSURLConnection for chunked transfer encoding

烂漫一生 提交于 2019-11-27 16:23:53
问题 I've checked for other questions relevant to this, but the only answer is "Use ASIHTTPRequest " as this is no longer being developed I wanted to ask what alternatives people are using, whilst working on our SDK I came across a lot of strange behaviour in NSURLConnection when receiving data from the server. We tracked it down to the fact that NSURLConnection doesn't deal well with responses in chunked-encoding. Or at least so we read in this question here NSURLConnection and "chunked" transfer

MBProgressHUD with NSURLConnection

こ雲淡風輕ζ 提交于 2019-11-27 15:23:51
问题 I was trying to use MBProgressHUD with NSURLConnection. The example in Demo project of MBProgressHUD reports: - (IBAction)showURL:(id)sender { NSURL *URL = [NSURL URLWithString:@"https://github.com/matej/MBProgressHUD/zipball/master"]; NSURLRequest *request = [NSURLRequest requestWithURL:URL]; NSURLConnection *connection = [[NSURLConnection alloc] initWithRequest:request delegate:self]; [connection start]; [connection release]; HUD = [[MBProgressHUD showHUDAddedTo:self.navigationController

NSURLConnection doesn't call delegate methods

爱⌒轻易说出口 提交于 2019-11-27 14:44:51
问题 I saw similar questions here, but I couldn't find solution to my problem. I have a simple NSURLConnection in main thread (At least I didn't create any other threads), but my delegate methods aren't get called [[[NSURLConnection alloc] initWithRequest:request delegate:self] autorelease]; and no methods called, e.g. - (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response { NSLog(@"didReceiveResponse"); } self is also a delegate for NSXMLParser, but I think

How to handle “CFNetwork SSLHandshake failed” in iOS

非 Y 不嫁゛ 提交于 2019-11-27 14:33:56
Some times i'm getting CFNetwork SSLHandshake failed -(9806) in my code,but i'm not sure why this is happening as my code runs smoothly,except when i run it in iOS 6 and then on iOS 7 64-bit i get this warning. Can anybody suggest me, how to handle this issue ? Normally when I get CFNetwork SSLHandshake failed -(*) Its because of my local wifi network (device is connected to network but not the internet) Try it again on another network (3G is the quickest solution for me) Antoine This could also happen because of iOS 9. iOS 9 and OSX 10.11 require TLSv1.2 SSL for all hosts you plan to request

UIImage to be displayed progressively from server

孤街醉人 提交于 2019-11-27 13:02:02
问题 I have been trying to display large image from server, but I have to display it progressively. I used subclass of UIView and in that I have taken UIImage object, in which I used NSURLConnection and its delegate methods, I also used - (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data; in which I am appending data and converting it to UIImage object, and drawing rect using the drawInRect: method of UIImage . Everything is working fine, but the problem is, when image