Questions tagged [nscache]

NSCache is a cache-related class included in Apple's Foundation framework.

NSCache is similar to NSMutableDictionary, with the differences being:[1]
1. It is guaranteed to be thread-safe.
2. It is much slower to access.
3. It may throw out objects from time to time. You can set costs and limits, but they're not guaranteed to be followed.
4. It is not toll-free bridged to anything in CoreFoundation.
5. You can't query the number of objects that are in the cache.
6. You can't enumerate a cache.

154 questions
3
votes
2 answers

Downloading From Parse on Apple TV

I have a parse server set up, and as part of it, small PDFs (425KB) are stored on it. I need my Apple TV to be able to display these, but since they change often, it has to come from Parse server, and not just the main bundle where I update it with…
user717452
  • 33
  • 14
  • 73
  • 149
3
votes
0 answers

SwiftUI NSCache cache object

Hi everyone there is a method simil NSCache used in Swift with Class for SwiftUI? Ive try NSCache but not work with Structure. thanks
Stefano Toppi
  • 626
  • 10
  • 28
3
votes
0 answers

How to cache a file e.g PDFDocument, to prevent re-loading and increase user experience - swift?

I have an app with a collection view that displays thumbnails of pdf documents. When a user taps on the thumbnail a new UIViewController is presented along with the PDFDocument. I am trying to cache the PDFDocument so that the app does not have to…
dean
  • 321
  • 3
  • 17
3
votes
1 answer

How to know if an NSCache is empty?

If I'm not wrong, there is no way to know the number of the objects stored in an NSCache, but is there any way to just know if the cache is empty or it already contains any object?
AppsDev
  • 12,319
  • 23
  • 93
  • 186
3
votes
1 answer

NSCache objectForKey: always return nil after memory warning on iOS 8

I came across a problem that only happened on iOS 8. I used the NSCache to store my images. After receiving memory warning, I would fetch images and store into cache again. However the cache can't store my images anymore after warning. It always…
yuhua
  • 1,239
  • 8
  • 18
3
votes
4 answers

How to Clear PFFIle Cache (Parse.com)

I have an app that downloads and displays a lot of images from parse. An image is added to the database almost every minute. Since PFFile is automatically cached with no expiration date, even though I only need to display recent images, the older…
Subash
  • 1,002
  • 13
  • 26
3
votes
0 answers

NSCache with NSDiscardableContent or NSMutableDictionary?

Currently, I'm using NSCache to store data for my app. I can always retrieve that data again from the server, so it is not a problem if I eventually lose the data, that's why I'm using NSCache. The problem is that every time my app enters background…
Jorge
  • 1,492
  • 1
  • 18
  • 33
3
votes
2 answers

When does NSCache release the caches objects?

I have implemented a list where a number of large images are being loaded asynchronously. I am using an instance of NSCache to store these UIImage files. As I scroll down, I load more and more images. I set this up and was profiling the app for…
Rameez Hussain
  • 6,414
  • 10
  • 56
  • 85
3
votes
1 answer

error in implementing nscache

im having this error 2013-08-20 17:06:57.500 AceXMLSample[13602:11303] *** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[ valueForUndefinedKey:]: this class is not key value coding-compliant for…
Ace Munim
  • 325
  • 3
  • 18
3
votes
1 answer

NSCache to store images for UITableView

I have a view controller with a table view. in each cell of the table view, i have an image which is fetched from the net - but many of them have the same image. so, what i'm doing currently is storing the fetched images in a NSCache object. it…
3
votes
1 answer

Does NSCache persist between launches?

I'm looking into a fairly simple mechanism for caching and and currently using NSCache (for the reason of memory management). Question is - does the cache persist between launches? It seems like no to me. I get objects put in cache just fine and can…
Live2Enjoy7
  • 1,075
  • 2
  • 11
  • 22
2
votes
1 answer

how can I cache an image in swift 5?

I am having trouble finding a good example of how I can cache images in a table view using URLSession to get image from the internet (API). However, I am getting issues with the cache - Here is my code so far: func configure(with urlString: String,…
jo1
  • 115
  • 1
  • 12
2
votes
2 answers

How to cache images in Objective-C

I want to create a method to cache an image from an URL, I got the code in Swift since I had used it before, how can I do something similar to this in Objective-C: import UIKit let imageCache: NSCache = NSCache() extension…
Didami
  • 210
  • 2
  • 14
2
votes
2 answers

How to put image to NSCache in Swift?

I make some code using swift 4 to load image from URL, but every time I add images to server, it took a lot of time to load it in colection view or table view. I want to try store it in NScache but i dont understand to do it. can anyone help me, I'm…
Nicho
  • 606
  • 1
  • 10
  • 24
2
votes
2 answers

NSCache and persistence?

My app performs searches of some items and downloads an image per each result it gets. It shows the results on a tableView, a cell per result, and each cell shows the corresponding image. I'd like to cache the images to avoid being downloading the…
AppsDev
  • 12,319
  • 23
  • 93
  • 186
1 2
3
10 11