Question

Is there a way to inspect NSCache's contents for debugging purposes?

This would not be used in the App Store. I just would like to be able to see what's going on in there while debugging. The description is pretty useless.

Was it helpful?

Solution 2

There is an open-source replacement for NSCache that solves this exact issue: https://github.com/gregkrsak/GKCache

OTHER TIPS

No need to use a third party library. You can do this using the "allObjects" key from NSCache. For example:

if let all = yourCache.value(forKey: "allObjects") as? NSArray {
    for object in all {
        print("object is \(object)")
    }
}

NSCache doesn't have such feature. But you can use custom solution, e.g.: VSCache

It's thread-safe and easy to use.

You can see all keys and objects with

-[NSCache mapTableRepresentation]

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top