• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: How to manage (My)SQL data in Cocoa
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to manage (My)SQL data in Cocoa


  • Subject: Re: How to manage (My)SQL data in Cocoa
  • From: Quincey Morris <email@hidden>
  • Date: Sun, 9 Nov 2008 09:47:49 -0800

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 (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


  • Follow-Ups:
    • Re: How to manage (My)SQL data in Cocoa
      • From: dreamcat7 <email@hidden>
References: 
 >How to manage (My)SQL data in Cocoa (From: Michele Barboni <email@hidden>)

  • Prev by Date: How to manage (My)SQL data in Cocoa
  • Next by Date: NSArrayController, bindings and NSUserDefaults
  • Previous by thread: How to manage (My)SQL data in Cocoa
  • Next by thread: Re: How to manage (My)SQL data in Cocoa
  • Index(es):
    • Date
    • Thread