Note that there are some explanatory texts on larger screens.

plurals
  1. PONSURLConnection delegate methods not being called
    primarykey
    data
    text
    <p>I'm trying to use the delegate methods of NSURLConnection. The following methods are currently not being called:</p> <pre><code>- (void)connectionDidFinishLoading:(NSURLConnection *)connection; - (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data; - (void)connection:(NSURLConnection *)connection didReceiveAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge; //I also want to be able to use self-signed https urls - (BOOL)connection:(NSURLConnection *)connection canAuthenticateAgainstProtectionSpace:(NSURLProtectionSpace *)protectionSpace; //I also want to be able to use self-signed https urls </code></pre> <p>I'm currently using a synchronous call but asynchronous seems better because after I complete the code base I'm going to implement it into an iPhone application and I can't have my ui freezing.</p> <p>With the following method<code>responseData = [NSMutableData dataWithData:[NSURLConnection sendSynchronousRequest:request returningResponse:&amp;response error:&amp;error]];</code> </p> <p>I get back the data I need but using asynchronous I seems I have to use the delegate methods to get data back. I tried to add the delegate by using <code>@interface myClass : NSObject&lt;NSURLConnectionDelegate&gt;</code></p> <p>I'm calling my method as follows:</p> <pre><code>-(void)grabData{ NSArray* array = [NSArray arrayWithObjects:@"auth.login",@"user",@"pass", nil]; NSData* packed_array = [array messagePack]; NSURL* url = [NSURL URLWithString:@"https://192.168.1.115:3790/"]; NSMutableURLRequest* request = [[[NSMutableURLRequest alloc]initWithURL:url]retain]; [request setHTTPMethod:@"POST"]; [request setValue:@"RPC Server" forHTTPHeaderField:@"Host"]; [request setValue:@"binary/message-pack" forHTTPHeaderField:@"Content-Type"]; [request setValue:[NSString stringWithFormat:@"%d",[packed_array length]] forHTTPHeaderField:@"Content-Length"]; [request setHTTPBody:packed_array]; //NSHTTPURLResponse *response = nil; NSError *error = nil; NSLog(@"connecting"); NSURLConnection* connection = [[[NSURLConnection alloc]initWithRequest:request delegate:self]retain]; if (connection) { NSLog(@"connection exists"); self.responseData = [[NSMutableData data]retain]; } else { NSLog(@"Connection doesn't exist?"); } NSLog(@"response data: %@",[responseData messagePackParse]); NSLog(@"error: %@",error); } </code></pre> <p>I've attempted the following:</p> <pre><code>NSURLConnection *connection = [[NSURLConnection alloc] initWithRequest:request delegate:self]; [connection start]; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload