Questions tagged [nsurlconnection]

An NSURLConnection is the Apple Foundation Framework class that provides support to perform the loading of a URL request. It is deprecated and should be replaced by NSURLSession.

An NSURLConnection object provides support to perform the loading of a URL request. The interface for NSURLConnection is sparse, providing only the controls to start and cancel asynchronous loads of a URL request.

It is deprecated in iOS 9.0 and OS X 10.11 and should be replaced by NSURLSession.

NSURLConnection Class Reference

3110 questions
21
votes
4 answers

Check if NSURL returns 404

I need to check whether a URL (represented by a NSURL) is available or returns 404. What is the best way to achieve that? I would prefer a way to check this without a delegate, if possible. I need to block the program execution until I know if the…
Erik
  • 11,944
  • 18
  • 87
  • 126
20
votes
6 answers

Ignoring certificate errors with NSURLConnection

I am getting this error The certificate for this server is invalid. You might be connecting to a server that is pretending to be "server addres goes here" which could put your confidential information at risk." I am using this…
Ideveloper
  • 1,467
  • 4
  • 23
  • 44
19
votes
2 answers

When is a NSURLResponse not a NSHTTPURLResponse?

I've seen a lot of code, including Apple's SimpleURLConnections sample, that simply cast any NSURLResponse to a NSHTTPURLResponse. If it is always a NSHTTPURLResponse why do the NSURLConnections not return NSHTTPURLResponse? I'm worried that if I…
CornPuff
  • 1,924
  • 20
  • 24
19
votes
3 answers

_kCFStreamErrorCodeKey=-2102 only with wifi of some ISPs

I use below code to send a file to the server: NSString *urlString = [NSString stringWithFormat:@"%@%@",[LIUtility sharedUtility].uploadConnectionURL,BR_SERVER_UPLOAD_ADDRESS_FILE]; self.request =[[NSMutableURLRequest alloc] init]; [self.request…
Husein Behboudi Rad
  • 5,434
  • 11
  • 57
  • 115
19
votes
1 answer

NSURLConnection deprecated in iOS9

I want to download a file with a NSURLRequest and save it but in the line with the NSData * data = ... happens an error. NSURL *Urlstring = [NSURL URLWithString:@"http://yourdomain.com/yourfile.pdf"]; NSURLRequest *request = [NSURLRequest…
Maximilian
  • 754
  • 1
  • 5
  • 26
19
votes
2 answers

error handling with NSURLConnection sendSynchronousRequest

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…
Nnp
  • 1,813
  • 7
  • 36
  • 62
19
votes
1 answer

How to know if a NSURLResponse comes from cache?

I set NSURLCache on a specific folder (../../Application Support/Offline so it won't be deleted randomly by the OS), then I send a NSURLRequest with NSURLRequestReturnCacheDataElseLoad policy. How can I tell that the response, handled by a class…
18
votes
5 answers

When does NSURLConnection's initWithRequest return nil

Does anyone know in which situations initializing a NSURLConnection returns nil instead of the created connection. The documentation says it's possible but fails to specify when this happens. The method/message in question: [[NSURLConnection alloc]…
ynnckcmprnl
  • 4,382
  • 1
  • 24
  • 25
18
votes
1 answer

HTTP Status Code 411 - Length Required

I try to get data from server. I use NSURLConnectionDelegate, NSURLConnectionDataDelegate. There is code (Objective - C). -(void)sendRequest { NSURL* url = [[NSURL alloc] initWithString:@"http://SomeServer"]; NSMutableURLRequest* request =…
18
votes
3 answers

How to cancel a persistent connection using NSURLConnection?

Is it possible to destroy a persistent connection that has been created with NSURLConnection? I need to be able to destroy the persistent connection and do another SSL handshake. As it is now, calling [conn cancel] leaves a persistent connection…
jblack
  • 821
  • 8
  • 14
17
votes
4 answers

How to use NSURLConnection completionHandler with swift

Does anybody know how handlers (blocks) work in swift? I am trying to get this code running but i can't find any documentation of the right syntax for the completionHandler. let url:NSURL = NSURL(string:"some url") let request:NSURLRequest =…
loopmasta
  • 1,693
  • 3
  • 14
  • 19
16
votes
11 answers

UIImage to be displayed progressively from server

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 -…
16
votes
6 answers

Can't reauthenticate with different NSURLCredentials (old deleted ones are used)

i've been searching stackoverflow, google, apple and other places. The tips provided look promising, i implemented them but alltogether don't seem to work or get enforced. Problem: I have an NSURLConnection with specific credentials. I then have a…
Mike F
  • 1,224
  • 4
  • 26
  • 44
16
votes
4 answers

Why should I prefer ASIHTTPRequest over NSURLConnection for downloading files from the web?

I've seen a couple of times people using ASIHTTPRequest to download files. Now I wonder why? What are the core benefits over NSURLConnection?
Proud Member
  • 40,078
  • 47
  • 146
  • 231
16
votes
2 answers

Perform POST request in Swift

I am trying to do something like this: NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"http://google.com"]]; request.HTTPMethod = @"POST"; NSString *stringData = @"some data"; NSData *requestBodyData =…
Jake Johnson
  • 1,856
  • 1
  • 17
  • 26