nsurlconnection

NSURLConnection timeout?

I'm using this NSURLConnection with delegates. nsconnection = [[NSURLConnection alloc] initWithRequest:request delegate:self startImmediately:YES]; Problem is the website doesn't respond at all. Nothing, just spins in browser with blank page, no failure. In my delegates, I handle the failure, but when the site doesn't respond the ...

NSURLConnection Crashing

I'm implementing back-end data loading with a server by creating an NSOperation and opening NSURLConnections synchronously. This code was working perfectly in both the simulator and the device until I added a progress bar with notifications going back to the main thread. - (void)start { // stop execution if it's cancelled i...

Handling redirects correctly with NSURLConnection

For the purposes of this, I'm going to pretend the original url is http://host/form and the new url is https://host/form. (Note that before I ship this, both URLs are going to be secure. However, the nonsecure-to-secure seems like a convenient redirect to test this on.) I'm accessing a web API using NSURLConnection that redirects me. Ba...

iPhone NSURLConnection through Proxy+Auth

I am using NSURLConnection to make connections to a server, through a proxy that requires authentication this fails. The proxy settings are set under the WiFi, but the connection still fails. I believe there is a part of CFNetwork that can fix this, but this might be just for streams and I am unsure of how to implement it with NSURLConne...

NSMutableURLRequest timeout interval not taken into consideration for POST requests

I have the following problem. On a NSMutableURLRequest using the HTTP method POST the timeout interval set for the connection is ignored. If the internet connection has a problem (wrong proxy, bad dns) the url request fails after about 2-4 minutes but not with NSLocalizedDescription = "timed out"; NSUnderlyingError = Error Domain=k...

How can (void) connectionDidFinishLoading RETURN something?

Hi everybody I have this simple scenario: main.m (which is my main class) myClass.m (which is an additional class) In my plans it should happen something like this (in MAIN.m) myClass *foo = [[myClass alloc] init]; NSArray *array = [foo returnAnArray]; What myClass does is opening a new NSURLConnection, retrieving some data and ...

NSURLConnection delegate gets called after caller functions control is finished

i am following code from apple examples. this code is used in a method called login and i call this method from another class ABC. My problem is this when i call the Login method it will execute the code NSURLConnection *theConnection=[[NSURLConnection alloc] initWithRequest:theRequest delegate:self]; if (theConnection) { received...

Changing the userAgent of NSURLConnection

Hey I am using a NSURL Connection to receive data. [NSURLConnection sendSynchronousRequest: //create request from url [NSURLRequest requestWithURL: //create url from string [NSURL URLWithString:url] ] //request parameters returningResponse:nil error:nil ] Is it possible to change the user agent string? right now it is: AppName/...

How to measure size of NSMutableURLRequest 's response before http-ungzip

One of my view needs a big JSON file for tableview. I use gzip in HTTP request, but want to be sure of size. The problem: How to measure size before and after ungzip? or how to know how strong gzip is? This my code sample: NSURL *url=[NSURL URLWithString:urlWithDate]; NSMutableURLRequest *urlR=[NSMutableURLRequest requestWithURL:url ...

meta http-equiv="Refresh" and NSURLConnection

Hi all, I have a URL e.g. http://www.test.com that contains a meta redirect as follows: However, - (void)connectionDidFinishLoading:(NSURLConnection *)connection just returns the initial data from the first URL. Is it now my responsibility to parse the returned HTML file and pull out the meta url attribute and call NSURLConnection a...

When to call release on NSURLConnection delegate?

Hi, When passing a delegate to the a NSUrlConnection object like so: [[NSURLConnection alloc] initWithRequest:request delegate:handler]; when should you call release on the delegate? Should it be in connectionDidFinishLoading? If so, I keep getting exec_bad_access. I'm seeing that my delegates are leaking through instruments. Than...

Memory allocation, release and NSURLConnection in iPhone app

I'm hoping someone can help me with this. I'm struggling to find an answer to what should be an easy question. By the way, this is my first major obj-c project after years of using c and c# so feel free to point out things I'm failing on. I have an iPhone app designed to load an album of photos into a UIScrollView. It also has a rand...

Reuse NSURLConnection objects?

I've got an app that will be doing a fair amount of communication with a server over HTTP, and these connections may be overlapping. I'm planning to load the data asynchronously. I understand that there is a performance hit associated with allocating memory, so I figured the smart thing to do would be to keep a set of available connect...

NSURLConnection Leaks -- Why?

NSURLConnection *connection is a property of the class @property (nonatomic, retain) NSURLConnection *connection; Instruments is reporting that I'm leaking an NSURLConnection object in the second line of the code below. NSURLRequest *request = [[NSURLRequest alloc] initWithURL:_url]; self.connection = [[NSURLConnection alloc] initWit...

Asynchronous request to the server from background thread

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; i...

Populating NSImage with data from an asynchronous NSURLConnection

I have hit the proverbial wall trying to figure out how to populate an NSImage with data returned from an asynchronous NSURLConnection in my desktop app (NOT an iPhone application!!). Here is the situation. I have a table that is using custom cells. In each custom cell is an NSImage which is being pulled from a web server. In order to ...

EXC_BAD_INSTRUCTION with URLConnection initWithRequest

I have a weird error that I cannot seem to find any documentation or posts for. When I try to connect to my web service (changed URL for privacy) using the standard textbook method, I receive EXC_BAD_INSTRUCTION or EXC_BAD_ACCESS on [NSURLConnection initWithRequest]. The weirdest thing is that on occasion I can step over the offending ...

NSXMLParser Question

I'm writing a RSS feeder and using the NSXMLParser to parse an XML page for me. Everything works well. This is the code that handles the asynchronously connection: static NSString *feedURLString = @"http://www.example.com/data.xml"; NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:feedURLString]]; feed = [[[NSU...

Cancelling operation with connection inside

I have a NSOperation that downloads some data using NSURLConnection, it looks somewhat like this: .... - (void)main { .... while (!self.isCancelled && !self.isLoaded) { [NSRunloop currentRunLoop] runMode:NSDefaultRunLoopMode beforeDate:[NDate distantFutute]]; } .... } The problem is that from time to time connection han...

twitpic API not connecting (multipart/form-data) objective-c

I've put together this code from lots of research. Information on the twitpic API is here: http://twitpic.com/api.do#uploadAndPost Through debugging i can tell that the dictionary is good, and that it gets through all the methods, the request gets submitted, but then the NSLog method returns <>. I'm not sure where I could be goin...