Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a shortcut to get to the /Resources/ folder in iPhone development?

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?

like image 867
Jason Avatar asked Aug 03 '09 16:08

Jason


2 Answers

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.

like image 156
Rob Napier Avatar answered Oct 17 '22 01:10

Rob Napier


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.

like image 24
Codezy Avatar answered Oct 17 '22 01:10

Codezy