• 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 remove:
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSTreeController and remove:


  • Subject: Re: NSTreeController and remove:
  • From: Quincey Morris <email@hidden>
  • Date: Fri, 14 May 2010 16:55:51 -0700

On May 14, 2010, at 15:39, Tony Romano wrote:

> I have a NSOutlineView bound to a NSTreeController in class mode(i.e. each NSTreeNode represents my Node object).  Everything up to now is working fine.  I am trying to remove a single node in the outline view by calling [outlineView remove:self] as a test.  The documents are pretty simple and they state that the remove: method removes the selected item, simple enough.  I've put some test code around the remove.  The test code is looking at the selected node Before the remove then looking at the selected node again(assuming the controller picked a new selection).  The before and after are the same which is also reflected in the UI.  I verified this in the debugger.  Here's the snippet.
>
> 	...
> 	NSArray * selectedObjects = [outlineController selectedObjects];
>
> 	// Only selecting one node for the test, it should be at index 0.
> 	Node * node = [selectedObjects objectAtIndex:0];
> 	NSIndexPath * paths = [outlineController selectionIndexPath];
>
> 	[outlineController remove:self];
> 	selectedObjects = [outlineController selectedObjects];
>
> 	node = [selectedObjects objectAtIndex:0];
>
> 	paths = [outlineController selectionIndexPath];
>
>
> The canRemove binding which is hooked up to the menu item, is working(Menu Item is enabled).  Is there some setting I am completely overlooking. Searching has come up empty handed.

You read the documentation for 'remove:' but apparently not all of it:

> Special Considerations
> Beginning with Mac OS X v10.4 the result of this method is deferred until the next iteration of the runloop so that the error presentation mechanism can provide feedback as a sheet.

So of course it hasn't been done when you check immediately after invoking the 'remove:' action. If you want it to happen immediately, you would need to use 'removeObjectAtArrangedObjectIndexPath:' instead.

But ...

Depending on where this code is, it may be a lousy idea to do the removal via the tree controller anyway. You're always better off changing the data model directly (the thing that is providing the tree controller with content).

If I say this often enough, one day someone might listen.



_______________________________________________

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 remove:
      • From: Tony Romano <email@hidden>
References: 
 >NSTreeController and remove: (From: Tony Romano <email@hidden>)

  • Prev by Date: Re: NSDrawThreePartImage - Strange scaling behavior, is it supposed to do that?
  • Next by Date: Re: NSDrawThreePartImage - Strange scaling behavior, is it supposed to do that?
  • Previous by thread: NSTreeController and remove:
  • Next by thread: Re: NSTreeController and remove:
  • Index(es):
    • Date
    • Thread