views:

484

answers:

2

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?

+1  A: 

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.

Codezy
but this is only a read-only resource yes? you can't write to it there right? (2 backwards questions)
Aran Mulholland
+5  A: 

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.

Rob Napier