propertiesnsurlconnectiondelegationnsurlconnectiondelegate

How to access NSURLConnection Delegate property


Why is it not possible to do the following:

id connectionDelegate = myConnection.delegate;
//myConnection is an instance of NSURLConnection

Why is this not possible, and how do I access the delegate otherwise. Seems rather awkward to me, or am I missing something here?


Solution

  • NSURLConnection is pretty awkward. Why are you still using it? Unless you're trying to maintain backwards compatibility with iOS 6 or OS X v10.8 and earlier, just use NSURLSession.

    With that said, if you must keep using that API for backwards compatibility, you can always do what I've done in these situations: