Loading Data Files on iPhone?

What is the best way to load static data files containing game level maps on the iPhone? I have seen some use XML files, but that seems like overkill in my situation as the data files merely determine the layout of the game's level, ie where obstructions will go. Also, what project directory should they be stored in?

Thanks in advance!

Answers


If your files are really static, then you'll want to store them in your application bundle (just add them to your project; Xcode will copy them to the .app bundle when it builds your application). If you need to modify and re-save them, probably ~/Documents is your best bet.

Marc is correct, an NSDictionary is the simplest way to go, especially for smaller files. If you've got a LOT of data, this could get slow when loading in, but that means 10s, or 100s of kilobytes. Also think about converting your dictionary to binary format when you're happy with its contents, as that will load much faster on the device.


Need Your Help

Lazy Load Images in LI Tag sequentially as a batch

jquery lazy-loading

I have UL tag which has around 2000 images in LI tag under it. They display as a carousel. I am trying to Lazy Load them, They show a Loader gif and then show the Original Image.

GeoCoordinateWatcher - Increase Accuracy

c# wpf coordinates

I am starting to use the GeoCoordinateWatcher in C#. My problem is that even though I have the accuracy set to high, it is only returning 4 decimal places when I need it to return the exact coordin...

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.