• 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
Removing all objects in NSTreeController
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Removing all objects in NSTreeController


  • Subject: Removing all objects in NSTreeController
  • From: Andrew Merenbach <email@hidden>
  • Date: Sat, 24 Jun 2006 16:31:13 -0700

I'm trying to remove the entire contents of an NSTreeController, but the following fails to work:

- (void)removeAll:(id)sender {
	NSMutableArray *ips = [[NSMutableArray alloc] init];
	unsigned idx = [[self content] count];
	NSIndexPath *ip;

	while (idx--) {
		ip = [[NSIndexPath alloc] initWithIndex:idx];
		[ips addObject:ip];
		[ip release];
	}

	[self removeObjectsAtArrangedObjectIndexPaths:ips];
	[ips release];
}

Clearing the selection beforehand fails to help things, either. When the tree controller has multiple objects I end up with an the following error:

*** -[NSCFArray addObject:]: attempt to insert nil

I'm removing, not inserting, so I've no idea what's going on here. I'm also positive that I'm generating my selection indices correctly because using addSelectionIndexPaths: instead of removeObjectsAtArrangedIndexPaths: selects everything the way that one would expect.

Does anyone have an idea of what's going on with removeObjectsAtArrangedObjectIndexPaths: that the documentation that I've found doesn't seem to cover?

Also, and perhaps more importantly, is there a better way to "clear" an NSTreeController?

Many thanks,
	Andrew
_______________________________________________
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


  • Prev by Date: Re: closing window and having application remain running
  • Next by Date: Re: how do I determine if this is the first time the app is launched?
  • Previous by thread: Re: how do I determine if this is the first time the app is launched?
  • Next by thread: valueForKey and NSArray
  • Index(es):
    • Date
    • Thread