Take NSURLSession's task objects:
NSURLSession *session = [NSURLSession sessionWithConfiguration:[NSURLSessionConfiguration defaultSessionConfiguration] delegate:self delegateQueue:nil];
NSURLSessionDataTask *dataTask1 = [session dataTaskWithURL:[NSURL URLWithString:@"http://i.imgur.com/RARAP1J.jpg"]];
If I was in the following delegate method:
- (void)URLSession:(NSURLSession *)session dataTask:(NSURLSessionDataTask *)dataTask didReceiveData:(NSData *)data {
....
If I ended up creating a bunch of NSURLSessionDataTasks
, how would I go about checking which one dataTask
refers to. Sure, I could have a bunch of properties, but if I have 50 tasks, that gets unruly and I'd like to be able to automatically set it up in code.
I know of the taskIdentifier
method, which would work, but it's readonly
and I want to be able to set it.