Instance Method


Tells the delegate that the data task has received some of the expected data.


optional func urlSession(_ session: URLSession, dataTask: URLSessionDataTask, didReceive data: Data)



The session containing the data task that provided data.


The data task that provided data.


A data object containing the transferred data.


Because the data object parameter is often pieced together from a number of different data objects, whenever possible, use the enumerateBytes(_:) method to iterate through the data rather than using the bytes method (which flattens the data object into a single memory block).

This delegate method may be called more than once, and each call provides only data received since the previous call. The app is responsible for accumulating this data if needed.

Beta Software

This documentation contains preliminary information about an API or technology in development. This information is subject to change, and software implemented according to this documentation should be tested with final operating system software.

Learn more about using Apple's beta software