Note that there are some explanatory texts on larger screens.

plurals
  1. PONSHTTPURLResponse becomes NSURLResponse
    primarykey
    data
    text
    <p>I am using if-modified-since in the HTTP header to decide if I should download file. App was tested and everything was OK, but now I am getting errors when I ask my NSHTTPURLResponse instance <code>response.statusCode</code> or <code>[[response allHeaderFields] objectForKey:@"Last-Modified"]</code>. </p> <p>It seems to be just NSURLResponse. What are the possible reasons? </p> <p>I've read<a href="https://stackoverflow.com/questions/7396966/when-is-a-nsurlresponse-not-a-nshttpurlresponse">this topic</a> but the problem still is not clear for me. Thanks in advance! UPD: some code:</p> <pre><code> NSURL *url = [NSURL URLWithString:urlString]; NSFileManager *fileManager = [NSFileManager defaultManager]; NSMutableURLRequest *myRequest = [NSMutableURLRequest requestWithURL:url]; [myRequest setHTTPMethod:@"GET"]; NSDateFormatter *df = [[NSDateFormatter alloc] init]; df.dateFormat = @"EEE',' dd MMM yyyy HH':'mm':'ss 'GMT'"; df.locale = [[NSLocale alloc] initWithLocaleIdentifier:@"en_US"]; df.timeZone = [NSTimeZone timeZoneWithAbbreviation:@"GMT"]; [myRequest addValue:[df stringFromDate:lastModifiedLocal] forHTTPHeaderField:@"If-Modified-Since"]; myRequest.cachePolicy = NSURLRequestReloadIgnoringLocalAndRemoteCacheData; NSHTTPURLResponse *response=nil; NSError* error = nil; NSData* data = [NSURLConnection sendSynchronousRequest:request returningResponse:&amp;response error:&amp;error]; if (error) { NSLog(@"Error sending request: %@", [error localizedDescription]); } //As was advised NSHTTPURLResponse* newResp = (NSHTTPURLResponse*)response; //crash here NSLog(@"%d", newResp.statusCode); </code></pre> <p><strong>UPD:</strong> Error in code - myRequest and request are different variables. Problem solved.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload