small medium large xlarge

Back to: All Forums  Core Data
Generic-user-small
05 Aug 2009, 13:21
Tambet Väli (1 post)

Hello, my problem is that I want to use CoreData in fastest way possible for a data, which is not meant to be saved between sessions on iPhone. This is cache data for a network protocol. I’m pretty new to CoreData and Objective-C in general, so I haven’t all that background to find this information fast in manual. Most manuals tell me that I can store data in SQLite, XML file and many others. I’m interested in this many others - this is somewhat time-critical application as it has to render this dataset on screen 10FPS and I don’t want any kind of XML parsing, writing/copying data somewhere, re-creating this binary data in another format or doing any other such thing. All I want is to get 2 object contexts, one fetches data from net, parses it and calls “save” if it’s done, other is able to fetch data as it was before last save. Any kind of file manipulation, parsing and restructuring is unnecessary overhead. I want to use CoreData because some objects might be not full and usable right before receiving one packet, also because it’s standard and because it manages memory handling for me; also, I might later need it’s fetch constraints and such stuff - currently I plan to not use this constraint syntax as string parsing is not too fast, especially if I want a group of objects with specific ID’s.

Is there a simple way to achieve it - in-memory database for CoreData, I mean? And how to get 2 object contexts for that? - one should be normal object context got from sharedApplication delegate, another should be for writing operations.

Avatarsmall_pragsmall
25 Aug 2009, 16:24
Marcus S. Zarra (284 posts)

Yes you can use in-memory contexts. When you create the NSPersistentStoreCoordinator, there is an option to define what type of store you want to use. Use the in memory option instead of sqlite.

As for multiple contexts, you can have as many as you want, you just need to write the code for it yourself and you can base it off of the code in the templates.

I would be careful though. The iPhone is very limited in memory and I would be surprised if the sqlite store is not fast enough.

You must be logged in to comment