I want to add additional fields to NSMutableURLRequest
(for exapmle NSString
value requestID
) in order to determine correct handler for request when NSURLSession
completes it.
Is it legal to create a custom NSMutableURLRequest
's subclass to add specific fields? Apple documentation has no additional information about NSMutableURLRequest
subclassing.
UPDATE:
I discovered that NSMutableURLRequest
subclassing is not the best idea: background NSURLSession
can't create download task using my custom subclass object: method downloadTaskWithRequest:
always returns nil. I think this problem related with mutableCopyWithZone:
that called by NSURLSession
when it creates download task with request's copy.
Thanks.
I think that if Apple does not provide any warning of subclassing a class, then you can do it.