PDA

View Full Version : Coredata has App base and text files as backend for syncing




mraheel
Aug 8, 2012, 10:59 PM
How does this sound conceptually.

I wanted to store some text and add tags to it thats easily retrivable. Coredata is the obvious solution, but i also needed that data across the cloud, not just iCloud like dropbox. So I thot i'd use Coredata + textFiles.

obvious approach

use coredata with two entities. One for text and one for tags. Works awesome BUT not ready for syncing. 1. using icloud coredata combo will hurt me badly, its still unreliable, and i cant afford to keep stabilising it. 2. i dont just have ios devices, need it on my computer too.

the solution

Add text in a simple textview.
Add tags to the text as well using some kinda delimiters.
Save the document as a text file (that includes tags) and give the document some unique name
Put that file in dropbox or icloud or whatever as a document But Also, parse it locally in the iOS app so that the text in file is separated into text and tags each of which enters its entity in coredata.
advantage for the solution

I can use the text in a useful way locally (in iphone) and if needed will get those text files from the cloud.

problem with the solution

Data in the cloud (as textfiles) is only so useful. But nonetheless, its there, i can live with this.
SYNCING: how do i make sure that each file is synced appropriately. Im not sure I should use UIManagedDocument? I'm already using coredata locally, dont know how i'd complicate things if i use UIManagedDocument.
My question is, im confused about the syncing and saving part, what should i do to keep it neat and clean.

While writing this question i feel like I screwed up the whole idea.