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
0
votes
0 answers

NSCache - discarding content

I am using NSCache to store UIImage objects. I use UITableView to show the images and access the NSCache in the following manner: func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { let cell =…
surToTheW
  • 772
  • 2
  • 10
  • 34
0
votes
0 answers

NSCache not caching my files when tapping on UICollectionViewCell to view PDF document in another UIViewController - swift

I have a collection view application which when a cell is tapped on it loads up a pdf document in another UIViewController. These pdf files are found on a remote server. I am trying to cache these files using NSCache but without success. Every time…
dean
  • 321
  • 3
  • 17
0
votes
0 answers

Swift - How do I store objects in cache as long as the app is running? - NSCache() gets cleared as soon as other vc gets displayed

I am trying to save a custom class to cache, so that it doesn't have to be downloaded every time the vc is getting called. My problem is though that the cache gets cleared when I open a different vc, so that when going back to the "old" vc no…
Niklas M.
  • 1
  • 5
0
votes
0 answers

Use NSCache in Swift

I m using NSCache to save data for offline mode in app,but im not getting how to save that cache object in user default so that if app runs again data will be there in cache.I have created NSCache object in a Singleton Class. Any idea or alternate…
priyanshu
  • 155
  • 2
  • 11
0
votes
0 answers

How to cache the Images that is loaded in TableViewCell - Firebase and Obj-C

I use firebase to upload messages, images, videos. I'm able to upload and download the images, messages, and videos. However, when I populate data in UITableView and scroll the UITableView, the image gets changed for every scroll. How do I cached…
0
votes
1 answer

Caching downloaded images: FileManager / CachePolicy / URLCache / NSCache?

I'm need to implement the common scenario of having a table view with N cells where each of those cells needs to download an image to be displayed within it. The service protocol to call to download the images could be either HTTP or HTTPS. I am…
AppsDev
  • 12,319
  • 23
  • 93
  • 186
0
votes
1 answer

Images downloaded from Firebase are somehow taking up 28mb of memory a piece when they are only 200-400kb in size

I am using Firebase to host and download images for my app. Each image on Firebase ranges from 200kb-400kb, and the user downloads about 12 at a time as they scroll through a collectionView. When I launch the VC that downloads the images, my app…
Cody Lucas
  • 682
  • 1
  • 6
  • 23
0
votes
1 answer

How to use NSCache appropriately in iOS application?

I am building an application and want to use NSCache to store data for caching. There will be approx 5 API for which I need to cache data. Should I user NSCache? I did research for NSCache but I have some doubts regarding this. I did go through…
Jayeshkumar Sojitra
  • 2,501
  • 4
  • 31
  • 44
0
votes
2 answers

How to use NSCache and download Image From Url and Show images in CollectionViewCell?

I have a UICollectionViewCell and Inside that there is a imageView. My requirement is that I am getting Images Url from My_API and I want to download the Images from these Images Url and want to show them into a collectionViewCell imageView. First…
Kishor Pahalwani
  • 1,010
  • 1
  • 23
  • 53
0
votes
0 answers

Cache failing to save tableView cell image

I'm trying to save images in cache so that when I scroll up and down it doesn't have to download these images again. Unfortunately this doesn't seem to work because after all the images are downloaded when I scroll network activity goes up. Any…
0
votes
0 answers

how to iterate over NSCache values in Swift

I have this class: final class Manager { static let shared = NSCache() } I would like to iterate over all values to eliminate Heavier, how can I do?
0
votes
1 answer

How to Make iOS App Heavy in Network Requests Feel Responsive

I am working on an application that is socially-based. It mainly deals with creating schedules for a specific activity and inviting other users to join on a specific date and time. However, the application is using Parse as its backend. Almost every…
Nick Kohrn
  • 5,779
  • 3
  • 29
  • 49
0
votes
1 answer

Is there a way to store an array of optionals in NSCache?

I can't for the life of me figure out how to store anything to do with an optional in NSCache. I can understand directly storing an optional would not make sense, but storing an array or dictionary where some options may be optional certainly seems…
Doug Smith
  • 29,668
  • 57
  • 204
  • 388
0
votes
0 answers

ios: how to fix memory warning issue when showing lots of thumbnails(over 3000) by using NSCache?

I write a table view/collection view to show lots of photo. I use dispatch queue to load photo from Internet and use NSCache to cache photo (for not loading photo from internet again). when I loaded over 2000 photo, app received memory warning. I…
prettydog
  • 235
  • 3
  • 12
0
votes
0 answers

Is it possible to cache an array of images with NSCache?

I have an array of images that I download from the server. I need to cache them, and then bring them back to the controller from cache . How correct is this done? After NSCache takes only 1 object with a key ? We'll have to generate a key for each…
Zept
  • 1,158
  • 1
  • 10
  • 14