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
2 answers

Xcode iOS Image Caching

I am fetching images from my server and need to store them on the disk. I was wondering what is the best way to cache these images to prevent excessive requests and traffic. From doing some research it seems that there are many options available but…
dgee4
  • 381
  • 3
  • 16
0
votes
1 answer

Setting URL as key for NSCache not working

I extended NSCache and created a Singleton class as below +(instancetype)sharedDataCache { if (!sharedDataCache) { sharedDataCache = [[QDataCache alloc] init]; [sharedDataCache setTotalCostLimit:19999]; [sharedDataCache…
0
votes
1 answer

AFImageCache returns nil after restart

I am using AFNetworking version 2.5. I described my problem below. Thanks in advance. My problem: When I debug, I see AFNetworking downloads image and stores it to disk. After restart, cache for image remains in disk, however it does not return from…
Berk
  • 1,289
  • 12
  • 16
0
votes
1 answer

Can a WatchKit Extension access data from NSCache?

I know that we can get data from NSFileManager to get images from our app into our WatchKit extension - but we've been using NSCache to cache images in our iOS app. Is there a way to connect our WatchKit extension to images from NSCache? Here's what…
bryanjclark
  • 6,247
  • 2
  • 35
  • 68
0
votes
0 answers

NSCache is returning null after restarting project

I'm working with NSCache in Objective-C and Cocoa for iOS. Every time I restart the project, the getCacheRecommend call returns null and I expect it to return a value. #import @class ASJsonDiscoverModel; @interface…
0
votes
2 answers

How to check NSCache instance value set or not

I have an instance of NSCache, like: NSCache *imageCache; It is basically used for holding some remote "image" values with different "@keys". I alloc & init NSCache in a Global class at the beginning and set a if else condition, like this: if…
Tulon
  • 4,011
  • 6
  • 36
  • 56
0
votes
1 answer

Load remote server image in UIScrollView with NSOperatoinQueue

I want to load some "image" (In remote server) in a UIScrollView with NSOperatoinQueue. Because If I load it with normal NSURL, NSData or with NSMutableURLRequest it takes too much time to load for all the images. After that I show those images in…
Tulon
  • 4,011
  • 6
  • 36
  • 56
0
votes
1 answer

Swift: Generics & downcast to AnyObject

I have the following situation: (just copy it into a playground) import Cocoa protocol UID { var uid: Int {get set} } class A : UID { var uid = 01 } class manageUID { let cache = NSCache() func addUID(aObj: T) { …
Stephan
  • 4,263
  • 2
  • 24
  • 33
0
votes
2 answers

Cache Images in tableviewcontroller

I would like to save images into the cache in TableViewcontroller. I wrote the following code, but cacheImage is always nil. @property (nonatomic,strong)NSCache *imageCache; @synthesize imageCache; - (void)viewDidLoad { [super viewDidLoad]; …
user1724168
0
votes
1 answer

Does SDWebImage employ both memory caching and disk caching (when needed)? If not, how should I handle this?

My app deals with a lot of image downloads, and as such I want it to be as fast as possible for the user. Preferably, when the image downloads, it should never have to be downloaded again. My initial strategy was to save all the UIImages in an…
Doug Smith
  • 29,668
  • 57
  • 204
  • 388
0
votes
0 answers

Pngs being purge when app goes in background

I am using AFNetworking to save image from a Url, it uses NSCache to cache the images from the requested urls. When app goes in background and phone is locked, png's are being purged but jpegs are not.I read there is some auto expiration policy in…
Ashwani
  • 378
  • 1
  • 3
  • 13
0
votes
3 answers

NSCache expires after hit home button

I implement a customized class with NSCache to cache some article i found a problem, that is while hit the home button on simulator, the cached data seems gone it will load the data from network but not the cache if not hit home button, it will…
hlcfan
  • 313
  • 1
  • 2
  • 10
0
votes
2 answers

Best way to cache UIImage not from web

Hi i have high resolution image in local(document). Now i want to list all local images in thumb nail size. I am using UICollectionView to show image while loading resize the image from high resolution to thumbnail. So scrolling speed lack in…
Madhubalan K
  • 357
  • 5
  • 21
0
votes
2 answers

NSCache with hundreds of images

I got a collectionView which displays 9 images (200x300px) at a time. The total number can go up to hundreds, though. Currently I check in cellForItem if an Image is in the cache. If not, I'll load it from the file system and put it in the…
1b0t
  • 432
  • 1
  • 5
  • 11
0
votes
1 answer

Storing weak references in NSMutableDictionary

I'm implementing a cache,wherein I use NSMutableDictionary to store weak reference of objects.I know NSMaptable provides an efficient way to store weak and strong refereces.But its available on >=iOS6. My requirement is to support iOS>=5.Is there a…