• 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: Tree Data Structure in objc-C?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Tree Data Structure in objc-C?


  • Subject: Re: Tree Data Structure in objc-C?
  • From: Chris Hanson <email@hidden>
  • Date: Sun, 27 Nov 2005 22:53:03 -0800

On Nov 27, 2005, at 7:57 PM, David Chan wrote:

I was wondering what is the best approach to the following scenario:
I have a library application where I intend to store my books under some
categories. Now I have a NSOutlineView to do that interface wise. But how
should I store the categories? The problem is that user should be allowed to
create as many categories and subcategories as they want, much like the
behavior of folders tree. Also I need to associate each book with a
category, and users should have freedom to change the book's category, just
like the case of moving the file from one folder to another.

Core Data makes designs like this very straightforward. You just define your entities and the relationships between them, and then work with object graphs consisting of instances of those entities.


If you don't use Core Data, you'll need to consider carefully how object ownership works across your documents' object graphs in order to avoid retain cycles. The simple trick to avoiding that is to not have ownership between model objects in the object graph; your documents own their model objects and retain them (via "master" arrays or sets) while the model objects just relate to each other and don't retain.

  -- Chris

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


References: 
 >Tree Data Structure in objc-C? (From: David Chan <email@hidden>)

  • Prev by Date: How to Solve the Refreshing Problems of NSOpenGLView Placed in a NSScrollVIew
  • Next by Date: Re: Is Apple's singleton sample code correct?
  • Previous by thread: Re: Tree Data Structure in objc-C?
  • Next by thread: Re: Tree Data Structure in objc-C?
  • Index(es):
    • Date
    • Thread