5

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?

Jason
  • 17,276
  • 23
  • 73
  • 114

2 Answers2

9

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.

Jim Puls
  • 79,175
  • 10
  • 73
  • 78
Rob Napier
  • 286,113
  • 34
  • 456
  • 610
5

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.

elp
  • 8,021
  • 7
  • 61
  • 120
Codezy
  • 5,540
  • 7
  • 39
  • 48