On Nov 9, 2008, at 09:16, Michele Barboni wrote:

Currently I'm querying the database for a column at once, building an NSArray of them and add all NSArrays (the columns) in a NSMutableArray ("the table"). For editing I'm doing queries in the NSTableView controller (and I really don't like this).

So, I was wondering if there's a "standard" way for storing sql data (not sqlite and core data of course..) with Cocoa collections.

For example, I have thought to a NSDictionary with id integers as key and NSArrays with the rest of the *row* as values, sounds better but since I'm not an experienced programmer I'm asking..

If you're intending to read the entire database into memory, then the most natural "fit" with a NSTableView would probably be an array of dictionaries. The arrays would be rows, and each dictionary would contain the database column values for each row, keyed by a database column name. Then you could connect the table view columns to the dictionary with bindings, or use a data source where (say) the table column identifier was the dictionary key.

Or, instead of one dictionary per row, create a data model class that has a property (i.e. a setter and a getter, backed by a suitable instance variable) for each database column, and one object of this class per row. That would use slightly less memory than dictionaries, and allow you to customize the logic of data access. (The objects could keep track of what was changed, too, so that you could avoid queries at NSTableView editing time.)


_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to