Note that there are some explanatory texts on larger screens.

plurals
  1. POCallback from delegate to sender results in EXC_BAD_ACCESS error
    text
    copied!<p>I'm developing an application that uses NSURLConnection a lot. I want content to be loaded dynamically, so I have to implement a lot of delegates for this to work. In order to reduce the number of delegates, I created a class (AbstractURLConnection) that is &lt; NSURLConnectionDelegate>. <br /> <br /> I'm currently using a login view (and it's controller) to test the behavior of the NSURLConnectionDelegate class. Here are is my AbstractURLConnection class: <a href="http://pastebin.com/mpBEiHky" rel="nofollow">AbstractURLConnection</a></p> <p>In LoginViewController I then do the following:</p> <pre><code>@interface LoginViewController : UIViewController { AbstractNSUrlConnection *au; } @property (strong, nonatomic) AbstractNSUrlConnection &lt;NSURLConnectionDelegate&gt; *au; - (void) handleResponse:(NSMutableData *) data; </code></pre> <p>and in the .m file:</p> <pre><code>- (IBAction)login:(id)sender { NSURLRequest *req = [[NSURLRequest alloc] initWithURL:[NSURL URLWithString:@"http://myapp.dev:8887/users/login"]]; au = [[AbstractNSUrlConnection alloc] initWithRequest:req sender:self withSelector:@"handleResponse:" andRequestMethod:[AbstractNSUrlConnection MethodTypePOST]]; } - (void) handleResponse:(NSMutableData *) data{ NSLog(@"called back"); } </code></pre> <p>When I run the application, my LoginView pops up and when I press the login button, the <strong>login</strong> function gets called. The connection is established and the callback method (handleResponse) is called too.</p> <p>When I press the login button a second time, however, I get a EXC_BAD_ACCESS error to the <strong>handleResponse</strong> method.</p> <p>I suppose that the sender is cleaned up when I press the button a second time, but I don't know how to solve this. Any idea what might cause this?</p> <p>Thanks in advance,</p> <p>Jordy</p>
 

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