Question

Is there a shortcut method much like NSHomeDirectory() and NSTemporaryDirectory to get to the resources folder within your project?

Is the /resources/ folder the best place to be storing a file?

Was it helpful?

Solution

You can't store writable data in your Resources path, since it's inside the app bundle (which is signed). But it's a good place to store readonly data. As Codezy mentions, [[NSBundle mainBundle] resourcePath] is the path to it, but generally the better way to access files in it is [[NSBundle mainBundle] pathForResource:ofType:] and its siblings (...:inDirectory:, etc.) The latter automatically handles localization when appropriate.

OTHER TIPS

Yes, I store an SQL lite db in the resources folder. Here is a sample of how I get the path.

NSString *databasePathFromApp = [[[NSBundle mainBundle] resourcePath]        
                                       stringByAppendingPathComponent:@"ratings.sqlite"];

I store things in the resources folder if I want each new version to overwrite it, else I store it in the documents folder.

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