Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Inspect NSCache contents on iOS?

Tags:

ios

nscache

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.

like image 308
Steven Fisher Avatar asked Jan 24 '14 19:01

Steven Fisher


2 Answers

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)")
    }
}
like image 197
jjjjjjjj Avatar answered Oct 07 '22 18:10

jjjjjjjj


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

like image 23
proxi Avatar answered Oct 07 '22 19:10

proxi