Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Removing all objects in NSTreeController



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:
http://lists.apple.com/mailman/options/cocoa-dev/email@hidden

This email sent to email@hidden


Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.