Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

webphone

macrumors newbie
Original poster
Jan 18, 2010
4
0
There is a Resources folder which I store png images and sound files

e.g.
Resources/images/splash.png
Resources/sound/intro.caf

I want to store the path and file names in a xml or plist file.

So that it can be configured easily when development.

The XML schema:
<resources>
<images>
<file name="splash.png" />
</images>
<sound>
<file name="intro.caf" />
</sound>
</resources>

I am not sure how to create the plist to store those values.

I saw a code in a project but it seems to load the plist file:

[[CCSpriteFrameCache sharedSpriteFrameCache] addSpriteFramesWithFile:mad:"Splash.plist"];

My question is how is the objective-c code to load and cache resources files mentioned in xml / plist when app start?
 
You want two things:

1) When your app loads you want to read the plist file into an NSData object,

2) and then convert that into a NSDictionary to read your data from.

Look at the NSData, NSFileManager, and NSDictionary documentation, it should have what you need. Specifically look at the NSFileManager "contentsAtPath:UIPath" method which returns an NSData object, and the NSData method "propertyListFromData:NSData" method which returns a dictionary.

You can call that initialization stuff from basically anywhere you want, and just initialize your variables from the data in the dictionary.

Hope that helps.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.