Have tvOS CoreDataModel init's storeType default to CachesDirectory URL
cgoldsby opened this issue · 2 comments
cgoldsby commented
CoreDataModel init method storeType defaults to a SQLite DB using the Documents Directory URL: storeType: StoreType = .SQLite(DocumentsDirectoryURL())
On tvOS, the Document Directory is not available and it would be a nice enhancement to have the init method default to the Caches Directory.
A proposal would be to refactor DocumentsDirectoryURL() to DirectoryURL() and add an availability check when creating the directory URL:
var searchPathDirectory = .DocumentDirectory
#if os(tvOS)
searchPathDirectory = .CachesDirectory
#endif
return try NSFileManager.defaultManager().URLForDirectory(searchPathDirectory, ...)
jessesquires commented
Hey @cgoldsby ! 😄
Sounds like a great idea. Would you like to submit a pull request?
If so, let's call it DefaultDirectoryURL().
cgoldsby commented
Will do.