I'm trying to get the headers of the NSURLRequest with the following line:
NSString *contentType = [[(NSHTTPURLResponse *)data allHeaderFields] valueForKey:@"Content-Type"];
but I'm getting the following error:
-[NSConcreteMutableData allHeaderFields]: unrecognized selector sent to instance 0x8d876e0
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSConcreteMutableData allHeaderFields]: unrecognized selector sent to instance 0x8d876e0'
Any of guys know why of this error or how can I fixed or what I'm doing wrong?
I'll really appreciate your help
data
is a NSData
instance, not a NSHTTURLResponse
as you think.
That's why it doesn't recognize the selector allHeaderFields
that you're sending to it.