• 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: NSTreeController and insertObject:atArrangedObjectIndexPath:
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSTreeController and insertObject:atArrangedObjectIndexPath:


  • Subject: Re: NSTreeController and insertObject:atArrangedObjectIndexPath:
  • From: "Clark S. Cox III" <email@hidden>
  • Date: Sat, 19 Jun 2010 09:22:51 -0400

You should only need add your object to your model (which needs to me KVO compliant). The tree controller will then notice, in response to the KVO notification that a new item was added.

You should rarely, if ever, be direcly adding objects to the controller layer like this.

Sent from my iPhone

On Jun 18, 2010, at 18:53, Tony Romano <email@hidden> wrote:

> Scenario:  Adding a new node to a NSOutlineView backed by a NSTreeController.
>
> 1. Create a new internal object add add it to the data store(file system).  This will be my representedObject in the treecontroller
> 2. Compute the path and call insertObject:atArrangedObjectIndexPath:
>
> the treecontroller does 2 things during the call to insertObject:
>
> 1. It calls my getter, children, and asks me for all the children under the parent node I have added the new node to.  I give it the list INCLUDING the newly created node since it is now in the store.
> 2. Then it calls the setter, setChildren,  and gives me the newChildren list.  Which now has an additional copy of the new node, one from the getter call and one from the insertAt call. I know this for a fact because I purposely added some data to the newly created node for the insert to distinguish them.
>
> From the UI, the outlineview is correct, but my internal child list has the extra node.  It's not displayed because the treecontroller optimizes when to ask me for a childlist.  I have a work around which I don't like to basically lock out the getter method and just return the current child list(i.e the previous child list which doesn't have the new node added from the file system).  Anyone experience this before and have a recommendation?
>
> TIA,
> -Tony
>
> _______________________________________________
>
> 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: NSTreeController and insertObject:atArrangedObjectIndexPath:
      • From: Tony Romano <email@hidden>
References: 
 >NSTreeController and insertObject:atArrangedObjectIndexPath: (From: Tony Romano <email@hidden>)

  • Prev by Date: Re: NSTreeController and insertObject:atArrangedObjectIndexPath:
  • Next by Date: Re: DnD International No symbol
  • Previous by thread: Re: NSTreeController and insertObject:atArrangedObjectIndexPath:
  • Next by thread: Re: NSTreeController and insertObject:atArrangedObjectIndexPath:
  • Index(es):
    • Date
    • Thread