Re: writing & reading a file in Cocoa
Re: writing & reading a file in Cocoa
- Subject: Re: writing & reading a file in Cocoa
- From: Mike Ferris <email@hidden>
- Date: Sat, 28 Dec 2002 11:17:08 -0800
I agree with Scott that it seems like a fine use for NSUserDefaults
which will give your app a lot of standard niceties for dealing with
preferences, and make it consistent, and give advanced users standard
and known ways of interacting with your application's preferences.
Also, there are many many reasons not to write out C structures
directly (or send them over the wire, etc...). Scott mentioned one
which boils down to extensibility and versioning concerns. Another is
byte order and scalar size concerns. You really ought to stay away
from persistence strategies that do not account for potential changes
in endianess or data-size of your data. Even if you do not think your
data will ever need to work in a little-endian environment, 64 bit
machines will be along someday, and data-sizes will change. The more
you insulate yourself from such things by using standard mechanisms
like NSUserDefaults (storing NSNumbers), the less work you'll have
later when stuff shifts around under you.
Mike
Begin forwarded message:
From: Scott Anguish <email@hidden>
Date: Wed Dec 25, 2002 8:04:24 PM US/Pacific
To: Manooch Khajeh <email@hidden>
Cc: email@hidden
Subject: Re: writing & reading a file in Cocoa
On Wednesday, December 25, 2002, at 09:58 PM, Manooch Khajeh wrote:
Happy holidays:
I am writing a preference pane. I want to read & write a C data
structure into a file. Is there an example of this anywhere?
I prefer not to use NSDictionary and instead read & write the whole C
structure as a block of data bytes.
Why not use the preferences database via userdefaults?
It'd be better to write these items out in a non-C-structure way,
since this would give you better ability to change/add keys in the
future.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.