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
1
vote
4 answers

How to cache images and label texts downloaded from the internet for every uitableviewcell?

I download texts and image for every table cell from internet. I do it in background (GCD), but performance is not good (takes a while to dll images for all rows) because there are lots of rows. I use nsurlconnection for image dll. I googled a bit…
DixieFlatline
  • 7,895
  • 24
  • 95
  • 147
1
vote
1 answer

AFNetworking + Cached Image Placeholder

In short, I'm looking for a way to use a previously cached image as my placeholder in AFNetworking's UIImageView Category: - (void)setImageWithURLRequest:(NSURLRequest *)urlRequest placeholderImage:(UIImage *)placeholderImage …
djibouti33
  • 12,102
  • 9
  • 83
  • 116
0
votes
1 answer

What is diffrence between Objective-C NSCache.m and Foundation NSCache?

What is difference between Objective-C NSCache.m and Foundation NSCache? When I use NSCache in Swift, does it use Foundation's NSCache or Objective-C's? Foundation libs-base If you "jump to definition" about NSCache in Swift then Xcode shows the…
iOSDev
  • 3
  • 2
0
votes
0 answers

Swift cache (NSCache)

I am using NSCache to deal with cache in my app. Can anybody explain to me how totalCostLimit and countLimit works. I want to allow user input how may memory of using cache he wont to allow for our app and I understand that I need to use…
0
votes
0 answers

How can I remove a image from the cache with Combine in SwiftUI?

When I delete the data from array, the operation is successful, but only the picture does not change. The image still remains in the cache. However, when I close and open the application, the application works fine. how can i update the…
Ufuk Köşker
  • 1,288
  • 8
  • 29
0
votes
2 answers

Does NSCache gets automatically emptied when the app is force quitted?

I am downloading some images and save them in my cache. So far so good, but when quit my app and relaunch it, the cache seems to be empty. I do not know how to check if the cache is actually empty which is why I am asking if the cache gets…
JPJerry5
  • 107
  • 10
0
votes
1 answer

Set value to an cached image ends in crash

I am downloading an image and add it to my cache. That works fine, but when I want to add a value to my downloaded image in the cache, my code returns the error "Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[
JPJerry5
  • 107
  • 10
0
votes
2 answers

NSCache, Image Cache, not caching (Xcode 11, Swift 5)

I'm struggling to load cached image. On button press I'm either displaying an image if cached or downloading it then saving to cache. On the first click i get my label saying "Download From Web, and on the second click it loads from cache as I get…
user13209952
0
votes
1 answer

Wrong Images Loaded to TableView

This is my first time using NSCache for a table view. For cellForRow I call an NSCache loading an image. The image sometimes is the wrong image. What can I do to fix this? If the cache does not contain it, I replace the photo with "randomguy". func…
magellan
  • 63
  • 7
0
votes
0 answers

Is data coming from cache?

Requirement: Get the data from the cache if NSMutableURLRequest can not fetch data from the server.If internet available and i got the data from the server then function will return server data but if request fail to get the data from the server…
0
votes
1 answer

How to delete all cache in NSCache?

I am using NSCache for caching objects. Is there a way to delete all cache at once? I am using the following methods to cache: class VC: UIViewController { static let userCache = NSCache() func getUser(fromId id: String,…
Devxln
  • 556
  • 6
  • 18
0
votes
2 answers

cache image url not existing on rebuilding the project

I am implementing image caching in ios. Following is my function. struct DownloadImage { static let cache = NSCache() static func downloadImage(with url: URL,completion: @escaping (_ image: UIImage?) -> ()) { let dataTask =…
Arinjay
  • 69
  • 2
  • 7
0
votes
2 answers

SDWebImageOptions.refreshCached doesn't refresh cache

I've been having trouble getting my SDWebImage cache to update when an image is updated on my firebase storage backend. As suggested in other answers I've read here on stack exchange I've implemented .refreshCached but still the same image seems to…
0
votes
0 answers

Clear cache for particular app in iPhone settings

I am developing an iOS Application like Flipkart. So, I want to show many images on my dashboard. Every image was downloading in URLSession at every time app is open. So, I used NSCache to save some category of images. And also used local temp…
Kathiresan Murugan
  • 2,783
  • 3
  • 23
  • 44
0
votes
1 answer

Store Image with NSCache from Firebase - Objective C

Hello everyone I'm trying to use NSCache to manage the images taken from Firebase via URL .. I'm using NSCache because every time I browse the tableview with the photos of my users the imageView continually recompense so I wanted to use NSCache to…
kAiN
  • 2,559
  • 1
  • 26
  • 54