Why daltoniam Skeets offers NSDocumentDirectory as a location for cache files

The Skeets documentation, an image loader / cache structure written in swift for iOS / MacOS, shows in one example how to specify a caching path.

//set the cache directory. Only have to do this once since `sharedManager` is a singleton let paths = NSSearchPathForDirectoriesInDomains(.DocumentDirectory, .UserDomainMask, true) ImageManager.sharedManager.cache.diskDirectory = "\(paths[0])/ImageCache" 

My understanding so far has been that the document directory (and its subdirectories) is NOT the right choice for storing cache data, it even leads to a crash when viewing the application due to the fact that the Document Directory is copied by iCloud and the cache data is nothing we really want to create in the cloud.

Unless, of course, we exclude the directory that we specified from the iCloud backup explicitly.

I thought NSSearchPathDirectory.CachesDirectory would be a suitable place to store cache data?

+5
source share