Extensions on URLSessionDownloadTask can't be used

Originator:lievendekeyser
Number:rdar://28133379 Date Originated:02-Sep-2016
Status:Open Resolved:
Product:iOS SDK Product Version:iOS 10.0 (14A5339a)
Classification: Reproducible:Always
 
Summary:
Internally, NSURLSession uses __NSCFLocalDownloadTask, which doesn't inherit from NSURLSessionDownloadTask. This seems like bad practice to me anyway, since the API pretends it does (so somewhere along the line there's an object being cast to a type it doesn't conform to)

Steps to Reproduce:
1. Write an extension on URLSessionDownloadTask, adding e.g. a method to calculate the current progress of the download task
2. In one of the URLSessionDownloadDelegate methods, call this method on the incoming downloadTask argument

Expected Results:
Either the compiler should warn about extending URLSession*Task or the __NSCF implementations should respect the structure of the public interfaces

Actual Results:
An exception is thrown:

*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFLocalDownloadTask progress]: unrecognized selector sent to instance 0x7fd571ddb820'

Comments


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!