I am trying to implement download resuming functionality by using setValue:forHTTPHeaderField. But whenever I use that method, I get an
[NSURLRequest setValue:forHTTPHeaderField:]: unrecognized selector sent to instance 0x4e0b710 2011-08-08 22:44:36.469 Patch[9140:207] * Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSURLRequest setValue:forHTTPHeaderField:]: unrecognized selector sent to instance 0x4e0b710'
error.
My code works fine without that method but when I include this code, I get the error above
NSMutableURLRequest* request = [NSURLRequest requestWithURL:[NSURL URLWithString:URL]
cachePolicy:NSURLRequestUseProtocolCachePolicy
timeoutInterval:60.0];
//---------------- setting range for download resume -----------------------
NSString* range = @"bytes=";
range = [range stringByAppendingString:[[NSNumber numberWithInt:offset] stringValue]];
range = [range stringByAppendingString:@"-"];
NSLog(@"range: %@", range);
[request setValue:range forHTTPHeaderField:@"Range"];
please help me... Thank you very much
You need to create an NSMutableURLRequest
with an NSMutableURLRequest
.
NSMutableURLRequest* request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:URL]
cachePolicy:NSURLRequestUseProtocolCachePolicy
timeoutInterval:60.0];
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With