ios get the headers from NSURLRequest I get error [NSConcreteMutableData allHeaderFields]: unrecognized selector

StackOverflow https://stackoverflow.com/questions/15847737

Frage

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

War es hilfreich?

Lösung

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.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top