an AVAssetDownloadURLSession can't be downcasted if assigned to a more generic class
| Originator: | dmorrow | ||
| Number: | rdar://29625459 | Date Originated: | 12-Dec-2016 |
| Status: | Open | Resolved: | |
| Product: | iOS + SDK | Product Version: | iOS 10.1 |
| Classification: | AVFoundation | Reproducible: | always |
Summary: I'm creating an AVAssetDownloadURLSession through documented means. I'm assigning it to a property in another class, but that property is "NSURLSession". Since AVAssetDownloadURLSession is a subclass of NSURLSession, this is fine, and the compiler doesn't complain. Later on, I want to see if the session is an AVAssetDownloadURLSession by downcasting it. The downcast fails, even though I'm checking the memory address in the debugger, and it says it's the same as when it was created. The debugger does report it as an "__NSURLBackgroundSession", btw. But now I can't be certain if my session is an AVAssetDownloadURLSession, and this is a real problem. Steps to Reproduce: 1. Create an AVAssetDownloadURLSession. 2. define a varaiable like this: var someVar: URLSession = avURLSession 3. try to downcast: let downcastAVSession = someVar as? AVAssetDownloadURLSession Expected Results: I expect my downcast to work, and the value "downcastAVSession" be valid. Actual Results: the downcast fails, giving a nil result. Version: iOS 10.1 Notes: Here's my original post in the forums about this: https://forums.developer.apple.com/thread/69209
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!