I’m making my first iOS App, and I’m facing my first (little) issue.
The App will be a very classical iOS UI Experience : I mean, table views, tab bar, push controllers etc. displaying documents (from RTF files already existing), audio and video files.
My RTFs have mixed languages, all supported by iOS, I think it’s important isn’t it ?
Considering audio and video will obviously stored in the sandbox documents directory, I’m not so sure for the RTF.
I want it to be very reactive, on every devices, so my idea was to store my RTFs in a Core Data entity (using the binary type) and getting it in my application with NSAttributedString which can respond to the initWithRtf message.
I guess that after that I’ll have to load it into a UIWebView ? Or simply displaying this NSAttributedString into a textview will preserve it’s formatting ?
But I don’t know how to ship my application with a Core Data pre-filled database.
So here are my questions :
- Is it a good idea to store those RTFs in Core Data ? Is it really faster than a simple UIWebView where I would load the RTF file from documents folder directly ? Maybe SQLite is better for my case ?
- How to pre-fill a database into my application ?
- Any specific consideration about the multiple languages into my RTFs ? (Latin AND non latin languages into a same file for exemple).
Thanks a lot ! Bye.
That won’t work.
-initWithRTF:documentAttributes:is currently only available on OS X. To convert an RTF file into anNSAttributedStringon iOS requires manual parsing of the file at the moment (let’s hope that changes with iOS 5).UIWebViewcan’t displayNSAttributedStrings. Neither canUITextView. You would have to use the Core Text functions to draw the text yourself. Or use HTML from the beginning and display the text in a web view.What’s wrong with plain files? That would be my first option because it seems to be the simplest. You shouldn’t worry about optimizing something if you don’t know if it needs optimizing at all. But since you can store arbitrary binary data with Core Data or plain SQLite, it’s definitely possible.
Just include the Core Data datastore file in your app’s bundle. If this database needs to be written to, your code needs to copy the file from the bundle to your app’s Documents directory on first launch.