views:

52

answers:

1

I’m trying to decide the best way to load data into my app, it’s basically a book, but I want to have control of the chapter line number and chapter name ( so I can add comments and notes under relevant lines) etc. Both options allow me to do this. There’s going to be about 25 large-ish chapters.

What would be the best overall in terms of the iPhone platform? The data is already on my computer I just need to select which format is the best?

I think things like memory management and perhaps other limitations within the iphone need to be considered?

Are there any other factors which need to be taken into account?

Thanks guys,

Ok so here are the two possible options to load the data :

XML:

<toolTipsBook>
−  <chapter index="1" name="Chapter Name">
<line index="1" text="line text here"/>
<line index="2" text=" line text here "/>
<line index="3" text=" line text here "/>
<line index="4" text=" line text here "/>
<line index="5" text=" line text here "/>
<line index="6" text=" line text here "/>
<line index="7" text=" line text here "/>
</chapter>

SQL Dump

-- Chapter 1 (Chapter 1)
INSERT INTO `book_text` (`index`, `chapter`, `line`, `text`) VALUES
(1, 1, 1, ' line text here '),
(2, 1, 2, ' line text here '),
(3, 1, 3, ' line text here '),
(4, 1, 4, ' line text here '),
(5, 1, 5, ' line text here '),
(6, 1, 6, ' line text here '),
(7, 1, 7, line text here ');
+1  A: 

Apple's plist format is a good choice for hierarchical data on the iPhone. It's XML, but it's supported by Foundation, so importing is as easy as [NSDictionary dictionaryWithContentsOfFile:...].

I would suggest splitting everything into chapters and only keeping one or two loaded at a time if you're worried about memory.

cobbal
So that would be a better choice than using SQLite3 ?
Dave
I'm not familiar enough with SQLite to know, probably either would work. I would recommend this over creating your own XML syntax though.
cobbal
Thats the problem , as I could just as easily use the file as an SQL dump if I want to use SQLite . I just dont know what is the best choice for me?
Dave
Well, one solution would be to keep the data source sufficiently abstracted, then just pick one and go with it. A plist is probably easier, but if you find yourself later needing more speed or flexibility, you can switch your back end to SQL instead.
cobbal