I’m using an Objective-C class (UIView). In that class I’m calling an NSURLConnection (added NSURLConnectionDelegate to .h) When I start the connection, nothing happens. It’s not calling its methods. Is it just not possible to call NSURLConnection in a UIView class or am I doing something wrong?
Thanks.
First of all, it’s not enough to add
<NSURLConnectionDelegate>to your object’s interface declaration, you should explicitly set it as theNSURLConnection‘s delegate.Secondly,
UIViewis definitely a wrong candidate as anNSURLConnectiondelegate, because:UIViewis the view part of MVC;UIViewController.That makes
UIViewControllera better choice as anNSURLConnectiondelegate.