• 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: Help: Data Modelling, NSTreeController and NSBrowser
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Help: Data Modelling, NSTreeController and NSBrowser


  • Subject: Re: Help: Data Modelling, NSTreeController and NSBrowser
  • From: John Harte <email@hidden>
  • Date: Thu, 5 Oct 2006 11:36:00 -0400


On Oct 4, 2006, at 2:01 AM, Lachlan Deck wrote:

Hi John,

On 04/10/2006, at 1:54 PM, John Harte wrote:

On Oct 2, 2006, at 9:36 PM, Lachlan Deck wrote:

I have an entity defined called Category which has:
+ Attributes:
	- name (String)
+ Relationships:
	- category [toOne, Category optional]
	- subcategories [toMany, Category, optional]

From within Interface Builder I've instantiated an NSTreeController with bindings:
- Entity: Category (Automatically prepares content)
- Children keypath: subcategories
- Predicate: category == nil
- managedObjectContext: (Bind ticked)
- Bind to: AppDelegate
- modelKeyPath: managedObjectContext
And the NSBrowser:
- content:
- Bind to: TreeController
- controller key: arrangedObjects
- contentValues:
- Bind to: TreeController
- controller key: arrangedObjects
- Model key path: name



I don't know if this is the problem but in my NSBrowser I also have - selectionIndexPaths - Bind to: TreeController - Controller Key: selectionIndexPaths

Thanks very much for the suggestion. Unfortunately, I'm still getting the same error.


Any other ideas? What bindings do you have?


Here are the steps I used to get a document based browser to work:

Steps to create an NSBrowser view with core data.

New Project

Core Data Document-based Application

Edit Model (MyDocument.xcdatamodel)
	Add Entity
		Add Attribute: "name"
			Type: String
			Default Value: "name"

		Add Relationship: "parent"
			Destination: "Entity"

		Add Relationship: "children"
			Destination: "Entity"
			To-Many Relationship
			Inverse: "parent"

Open MyDocument.nib
	Add NSTreeController to nib
		Attributes
			Mode: Entitiy
			Entity Name: "Entity"
			Child Key Path: "children"
		Binding
			Parameters
				managedObjectContext
					Bind To: File's Owner (MyDocument)
					Model Key Path: managedObjectContext

	Remove NSTextField from window
	Add NSBrowser
		Bindings
			Browser Content
				content
					Bind To: NSTreeController
					Controller Key: arrangedObjects
					Model Key Path: Leave Blank
				contentValues
					Bind To: NSTreeController
					Controller Key: arrangedObjects
					Model Key Path: "name"
				selectionIndexPaths
					Bind To: NSTreeController
					Controller Key: selectionIndexPaths
					Model Key Path: Leave Blank
	Add Button
		Attributes
			Title: "Add"
		Connection
			Target NSTreeController's add: action
		Binding
			Availability
				enabled
					Bind To: NSTreeController
					Controller Key: canAdd
					Model Key Path: Leave Blank
	Add Button
		Attributes
			Title: "Add Child"
		Connection
			Target NSTreeController's addChild: action
		Binding
			Availability
				enabled
					Bind To: NSTreeController
					Controller Key: canAddChild
					Model Key Path: Leave Blank

I tried it with a non document based project and it worked.

Hope this helps.

John



_______________________________________________
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


  • Follow-Ups:
    • Re: Help: Data Modelling, NSTreeController and NSBrowser
      • From: Lachlan Deck <email@hidden>
References: 
 >Help: Data Modelling, NSTreeController and NSBrowser (From: Lachlan Deck <email@hidden>)
 >Re: Help: Data Modelling, NSTreeController and NSBrowser (From: John Harte <email@hidden>)
 >Re: Help: Data Modelling, NSTreeController and NSBrowser (From: Lachlan Deck <email@hidden>)

  • Prev by Date: Re: AVCVideoServices
  • Next by Date: Scrolling text in Status Item
  • Previous by thread: Re: Help: Data Modelling, NSTreeController and NSBrowser
  • Next by thread: Re: Help: Data Modelling, NSTreeController and NSBrowser
  • Index(es):
    • Date
    • Thread