views:

1737

answers:

2

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.

+4  A: 

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.

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"];
frankodwyer
Thanks, I didnt really know anything about bundles, so I wasnt sure where the files where being copied to.
Akusete
+2  A: 

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.

Akusete