Methods deprecated in NSURLConnectionDelegate


#1

Hello BNR.

I am working through the exercise on chapter 25 (3rd Ed). On page 443, we are instructed to implement the method connection:didReceiveData, which is defined in NSURLConnectionDelegate. That method, however, is deprecated. I copy the relevant section from my iOS 5.1 Library documentation:

– connection:needNewBodyStream
– connection:didSendBodyData:totalBytesWritten:totalBytesExpectedToWrite: required method Available in iOS 3.0 through iOS 4.3
– connection:didReceiveData: required method Available in iOS 2.0 through iOS 4.3
– connection:didReceiveResponse: required method Available in iOS 2.0 through iOS 4.3
– connection:willCacheResponse: required method Available in iOS 2.0 through iOS 4.3
– connection:willSendRequest:redirectResponse: required method Available in iOS 2.0 through iOS 4.3
– connectionDidFinishLoading: required method Available in iOS 2.0 through iOS 4.3

I wonder if anyone could point me to the new way of having the delegate call back when it receives data. None of the methods that were kept (connection:willSendRequestForAuthenticationChallenge:, connection:canAuthenticateAgainstProtectionSpace:, connection:didCancelAuthenticationChallenge:, connection:didReceiveAuthenticationChallenge:, connectionShouldUseCredentialStorage:) seems to do that.

Thank you and
Best wishes,

André


#2

I’ve found the answer. The methods were moved to a new protocol, NSURLConnectionDataDelegate, which in turn inherits NSURLConnectionDelegate.
Best,
André


#3

Great thanks fixed it :slight_smile:


#4

Thanks!!