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

2

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?

Wiles answered 3/8, 2009 at 16:51 Comment(0)
D
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.

Demetri answered 3/8, 2009 at 17:38 Comment(0)
S
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.

Sheepshearing answered 3/8, 2009 at 16:57 Comment(1)
but this is only a read-only resource yes? you can't write to it there right? (2 backwards questions)Ereshkigal

© 2022 - 2024 — McMap. All rights reserved.