Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7528923
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T04:31:04+00:00 2026-05-30T04:31:04+00:00

I am currently downloading and caching several different data sets from my server. However

  • 0

I am currently downloading and caching several different data sets from my server. However I am swapping all of my code from ASI over to NSURLConneciton stuff. and I am at the point where I am ready to pass my caches over to my parser delegates however they accept a NSData type as a parameter

- (void)startTheParsingProcess:(NSData *)parserData

where my cache is of type

NSCachedURLResponse

as you can see here

-(NSCachedURLResponse *)connection:(NSURLConnection *)connection willCacheResponse:(NSCachedURLResponse *)cachedResponse
{
    if (dataSetToParse == @"a"){
        NSCachedURLResponse *aCachedResponse = cachedResponse;

        aCachedResponse = nil;
        NSDictionary *newUserInfo;
        newUserInfo = [NSDictionary dictionaryWithObject:[NSDate date] forKey:@"Cached Date"];
        aCachedResponse = [[NSCachedURLResponse alloc] initWithResponse:[cachedResponse response] data:[cachedResponse data] userInfo:newUserInfo storagePolicy:[cachedResponse storagePolicy]];
        NSLog(@"%@", aCachedResponse);
        return aCachedResponse;
    }
    if (dataSetToParse == @"b"){
        NSCachedURLResponse *bCachedResponse = cachedResponse;

        bCachedResponse = nil;
        NSDictionary *newUserInfo;
        newUserInfo = [NSDictionary dictionaryWithObject:[NSDate date] forKey:@"Cached Date"];
        bCachedResponse = [[NSCachedURLResponse alloc] initWithResponse:[cachedResponse response] data:[cachedResponse data] userInfo:newUserInfo storagePolicy:[cachedResponse storagePolicy]];
        NSLog(@"%@", bCachedResponse);
        return bCachedResponse; 
    }
    return nil;

}

any example code would be helpfull thanks or just pointing me in the right direction 🙂

I am looking at the NSCachedURLResponse definition in the apple docs, and it says that NSCachedURLResponse has the data that I want I’m just not sure how I can get to it… to use with my parser delegates.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T04:31:05+00:00Added an answer on May 30, 2026 at 4:31 am

    You mean something like that?

    NSCachedURLResponse *cachedResponse = nil; // Put your code to get real response
    NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *)[cachedResponse response];
    NSData *responseData = [httpResponse data];
    

    NSCachedURLResponse has also a direct method data, but I cannot test if it’s the same result as the code above.

    Cache suggestion

    I see that you have your own methods that deal with caching. I would suggest subclassing the NSURLCache, if you need to modify caching and, say, add an offline mode. If you subclass it and implement some methods, like (but not limited to):

    – cachedResponseForRequest:
    – storeCachedResponse:forRequest:
    

    life may become easier for you. You would just set global app cache in application delegate through [NSURLCache setSharedURLCache:[CustomURLCache new]]; call.

    Then all your standard NSURL-whatever classes would behave as if they work with system cache, and you normally won’t have to deal with direct calls to get or store the cache, the system would call them automatically.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am currently downloading 471 thumbnails from a server,doubling the dimensions,saving it on the
Currently I am downloading and parsing my data from an XML file that is
In an iPhone app I currently have code for downloading a file from the
I am dealing with huge data (downloading from webserver to client/phone). Currently I am
I'm currently downloading an .mp3 file from a remote server and once the file
I'm currently downloading an HTML page, using the following code: Try Dim req As
I am currently writing a deployment script in MSBUILD, and after downloading several extensions,
I need help with downloading from webserver... What i currently do is get XML
I'm currently working on a website that imports XML data that we download from
My app is downloading packages of images from a server. It's an array of

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.