Objects returned by the `-[NSURLSession dataTaskWithURL:]` method lie about their class membership
| Originator: | cedric.luthi | ||
| Number: | rdar://14783825 | Date Originated: | 20-Aug-2013 03:24 PM |
| Status: | Open | Resolved: | |
| Product: | iOS SDK | Product Version: | 7.0b5 |
| Classification: | Serious Bug | Reproducible: | Always |
Summary: When an object documented to be a NSURLSessionDataTask instance is asked whether it’s a NSURLSessionTask (through the isKindOfClass: method), the result should be true since NSURLSessionTask is a superclass of NSURLSessionDataTask. Steps to Reproduce: Run this code: NSURLSessionDataTask *dataTask = [[NSURLSession sharedSession] dataTaskWithURL:[NSURL URLWithString:@"http://httpbin.org/get"]]; NSLog(@"isKindOfClass NSURLSessionTask: %@", [dataTask isKindOfClass:[NSURLSessionTask class]] ? @"YES" : @"NO"); NSLog(@"isKindOfClass NSURLSessionDataTask: %@", [dataTask isKindOfClass:[NSURLSessionDataTask class]] ? @"YES" : @"NO"); Expected Results: This log: isKindOfClass NSURLSessionTask: YES isKindOfClass NSURLSessionDataTask: YES Actual Results: This log: isKindOfClass NSURLSessionTask: NO isKindOfClass NSURLSessionDataTask: YES Regression: Other factory methods that return NSURLSessionTask subclasses instances are also affected by this bug. Notes: Here is a real world use case where this buggy behavior is problematic: https://github.com/AFNetworking/AFNetworking/blob/ab880d72ca2d3f401ec0180915f6f5056a2dd77d/UIKit%2BAFNetworking/AFNetworkActivityIndicatorManager.m#L35
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!
This issue has been addressed sometime between iOS 7.0b5 and now, I have no idea when. Of course the bug is still open in radar…