views:

623

answers:

2

I want to store some coordinates on a text files that correspond to an image array i will call out on my apps. Is it possible to write it in a notepad and save it as a .txt and be able to read in xcode the coordinates written inside or do i have to use plist format for that?

thank you.

+1  A: 

It is possible to read the text file just fine, but writing a plist is trivial and probably will make the reading easier. You can also directly write a header file with the coordinates:

// Coords.h
int coordinates[4] = {1, 2, 3, 4};

Depends on what exactly you need that for.

zoul
ok thanks for the quick reply. Just wondering also is it advisable also to just make another class just for the coordinates? Im probably storing a lot of coordinates coz im gonna use it later to compare to user touches coord.
Drahc
The header approach is a bit of a hack. Somebody might consider it overkill, but I’d probably wrap the coordinates into a class that would read the data from a plist. Then you can write a sample coordinate plist and check the loading routine using a unit test. Sounds complicated, but it should only take a while.
zoul
A: 

idevkit.com/iphonedev/2009/09/saving-nsmutablearrays/

this has a lot of info on reading and writing text files from an nsmutablearray.

Sj