Re: Storing structured data in file - any easy way?
Re: Storing structured data in file - any easy way?
- Subject: Re: Storing structured data in file - any easy way?
- From: Jules Colding <email@hidden>
- Date: Thu, 10 Jul 2008 20:29:58 +0200
Hi Graham,
On 10/07/2008, at 15.18, Graham Cox wrote:
Sounds like you want to do archiving - it can handle all the object
relationships you mention. Check out NSKeyedArchiver and the
NSCoding protocol.
http://developer.apple.com/documentation/Cocoa/Conceptual/Archiving/Concepts/archives.html
OK, this is just what the doctor ordered. But, I'd like an advise
please :-)
I want to store a rather large list of short string pairs and I want
to be able to be able to use both strings, in a given pair, as the
key. An example:
Assume that I want to store the set {"HI", "HELLO"}. At one point I
want to be able to use "HI" as key and get "HELLO". At another point I
want to use "HELLO" as key and get "HI".
There are several trivial ways to do this. I could use two
NSDictionary's and use the NSCopying protocol to store both.
Unfortunately that will make at least one, possibly both, dictionaries
present in memory at query time.
Another approach would be to make 2 files for each string pair: One
file named "HI" with the content "HELLO" and another with the name
"HELLO" and the content "HI". Unfortunately that will make a mess of
the filesystem, but at least it will be rather quick to get a value
for a given key.
The best solution seems to be some kind of lightweight database... Is
there any cocoa framework that implements a simple database or should
I manually seek through a file?
Thanks,
jules
hth,
Graham
On 10 Jul 2008, at 11:09 pm, Jules Colding wrote:
Hi,
I'm trying to figure out how to write and read structured data to a
specific file. I have a very bad feeling that the answer is Core
Data, but I'm feeling totally at lost after having been reading up
on Core Data for a couple of days by now.
This is what I would like to do:
1) I want to store several top-level objects.
2) A top-level object have a few optional attributes.
3) Each top-level object have two-way relationships to sub-objects.
4) Sub-objects has also a few optional attributes.
5) A top-level object may contain many sub-objects.
Obviously I would like to read and write to the data file as well
as create and delete objects within. There must be a simple way to
do this but I just can't figure out how...
Thanks a lot in advance,
jules
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden