10

How does one copy resource files (config/data/image) files to an applictions home directory on the iPhone.

A related question Loading Data Files on iPhone?, received an answer "just add them to your project; Xcode will copy them to the .app bundle when it builds your application".

How does one do this? (If this is a simple question, a manual reference/page# is fine)

I want to be able to copy a file onto the iPhone simulator and open it at runtime. I have tried to do this by adding 'copy file' targets, although I havent been able to find the files at runtime.

I know using property list, or sql lite database is prefered over file io, but I would still like to understand how to achieve this.

2 Answers 2

9

In my app, I have a sql lite DB which I just dropped in the root of my project folder and added to the resources folder of my project, and it winds up in the bundle, accessible by the app.

http://img68.imageshack.us/img68/3047/xcoderesourceslw5.png

I assume this will work for any file. I didn't have to write any special targets or operations.

In your app, this file then shows up as follows:

NSString *dbFilePath = [[NSBundle mainBundle] 
                            pathForResource:@"dictionary" 
                            ofType:@"db"]; 
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks, I didnt really know anything about bundles, so I wasnt sure where the files where being copied to.
3

I just found this site, Bundle Programming Guide it explains, how to access resources set in your project at runtime. I assume its just as easy to use single files.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.