In my iOS app, I'm downloading content from the web into my /Library/Caches directory. I'd like to represent this directory as an NSBundle for better compatibility with some of the external APIs we're using. (That way, we can simply change [[NSBundle mainBundle] pathForResource...] to [myBundle pathForResource...] whenever it appears.)
The following seems to work fine:
NSArray* paths = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES);
NSString* cachesDirectory = [paths objectAtIndex:0];
NSBundle* bundle = [NSBundle bundleWithPath:cachesDirectory];
Better yet, the bundle reflects any changes I make to the /Library/Caches directory. However, I'm concerned because the caches directory is technically not a bundle per Apple's docs. That is to say:
- It's not a "directory with a standardized hierarchical structure that holds executable code and the resources used by that code", since there's no code.
- It's neither an Application, Framework, nor a Plug-In bundle.
- It's most like an Application bundle, but it doesn't contain the required Info.plist or executable.
I could find no mention anywhere of this sort of dynamically-created, resource-only bundle. Is this okay to do?