views:

28

answers:

1

I have a library in both C# and Java that use some XML files to generate a lot of objects. I use them so I don't have to hardcode it in both languages, and can easily update the data.

In both C# and Java I can embed these files into the DLL/Package.

How would I proceed to do something like this in Objective-C?

+2  A: 

This isn't a language level question, it's a platform packaging level question. On both Mac OS X and iOS, typically you'll add the resource file to your project, then get the path to the file from NSBundle:

NSString *path = [[NSBundle mainBundle] pathForResource:@"file" ofType:@"xml"];

Libraries in Objective-C are called frameworks. Like applications, they are also bundles on Mac OS X and instead of mainBundle you probably want to use bundleForClass:.

iOS does not support frameworks, only static libraries, so you won't be able to include your resource files with your library on that platform. They must be added directly to the project.

Steve Madsen
So if I understand correctly for a iOS app, I need to add the library and seperately add the XML files to the iOS project?
Peterdk
Yes, that is correct.
Steve Madsen