• 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: dreamcat7 <email@hidden>
  • Date: Mon, 10 Nov 2008 15:36:32 +0000

Just to make even clearer what Quincey has said;

For NSTableView you MUST follow Quincey's conventions for the data representation. If you do not then simply the NSTableView control will not work. This is due to some very specific restrictions and limitations in the NSTableView Cocoa class. Its worthwhile to notice because otherwise you may have found necessary to rewrite some extensive amount of code for your data logic / or simply found this particular class unusable.

If sure that you dont need to see a TableView representation of the data (perhaps you have your mind set upon to use a different control such as NSOutlineView / or other ones ) then its probably be worth asking about those too. Certainly its going along the right lines to be asking about using an array or dictionary. Those representation will enable you to utilize some helper classes such as NSArrayController (and NSSortDescriptors for sorting) and perhaps certain parts of the Bindings / KVC will become relevant to you.

The following libraries are for executing basic SQL query from within the Cocoa environment and conveniently they can provide data into the NSArray etc;

Quicklite - 		http://www.webbotech.com/

FMDB - 			http://flycode.googlecode.com/svn/trunk/fmdb/
				http://code.google.com/p/flycode/source/browse/#svn/trunk/fmdb

PLDatabase - 	http://code.google.com/p/pldatabase/
(repackage of FMDB)


On 9 Nov 2008, at 17:47, Quincey Morris wrote:

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

_______________________________________________

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: mmalcolm crawford <email@hidden>
References: 
 >How to manage (My)SQL data in Cocoa (From: Michele Barboni <email@hidden>)
 >Re: How to manage (My)SQL data in Cocoa (From: Quincey Morris <email@hidden>)

  • Prev by Date: Floating point pixel data / image handling confusion
  • Next by Date: MVC and Cocoa question
  • Previous by thread: Re: How to manage (My)SQL data in Cocoa
  • Next by thread: Re: How to manage (My)SQL data in Cocoa
  • Index(es):
    • Date
    • Thread