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 7906847
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T11:09:24+00:00 2026-06-03T11:09:24+00:00

So the NSCache object should stay alive in order to keep the cached data,

  • 0

So the NSCache object should stay alive in order to keep the cached data, that means the same object that was used to store data, has to be used to retrieve data.

  • So the question is what’s the point of using NSCache over a singleton NSDictionary that holds my data?
  • What’s the preferred way to use NSCache? static field? inherit it and create a singleton?
  • 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-06-03T11:09:27+00:00Added an answer on June 3, 2026 at 11:09 am

    A cache has a number of quirks that make it work well as a cache while being poorly suited to use as a general purpose collection. As noted in the docs:

    NSCache objects differ from other mutable collections in a few ways:

    • The NSCache class incorporates various auto-removal policies, which ensure that it does not use too much of the system’s memory. The system automatically carries out these policies if memory is needed by other applications. When invoked, these policies remove some items from the cache, minimizing its memory footprint.
    • You can add, remove, and query items in the cache from different threads without having to lock the cache yourself.
    • Retrieving something from an NSCache object returns an autoreleased result.
    • Unlike an NSMutableDictionary object, a cache does not copy the key objects that are put into it.

    These features are necessary for the NSCache class, as the cache may decide to automatically mutate itself asynchronously behind the scenes if it is called to free up memory.

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

Sidebar

Related Questions

I've been using an NSCache to store items that should be cached for performance
I have an application that can be used without authentication on computers in public
I have 2 views that are using the same partial view. The first time
I am making a DownloadString function in order to retrieve HTML data (since the
What's the purpose of NSCache's name? The Apple docs only say that you can
I set a session object at one juncture in my code: Session(my_name) = Dave
I have a website that allows users to query for specific recipes using various
I need to customise the deployment of my liferay portlet such that the GWT
Error is something like that : Can't load Items.aspx from 192.168.0.172 And a text
I have been working on a JQuery script that posts JSON to my asp.net

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.