Hi all,

I'm having a problem with the -moveNode:toIndexPath: method of NSTreeController, which is new to 10.5.

I'm not using Core Data, I have a very simple model object like so:

@interface Item : NSObject {
        NSMutableArray* children;
        Item* parent;
        NSString* text;
        BOOL isRootItem;
}
@property(assign) NSMutableArray* children;
@property Item* parent;
@property (copy) NSString* text;
@property BOOL isRootItem;
-(id) initWithParent:(Item*) theParent;
@end

I am using the "children" property as the children key of the NSTreeController.

When I set up a hierarchy of these objects and call - moveNode:toIndexPath:, the object is moved correctly in the NSOutlineView but the model is not updated correctly.

Say I have a hierarchy like this:

Top Level Object 1
Top Level Object 2
        Sub Level Object 1
        Sub Level Object 2
        Sub Level Object 3
        Sub Level Object 4
Top Level Object 3
Top Level Object 4

If I move Top Level Object 1 to the index path [1][0], it should be inserted as a child of Top Level Object 2, before the existing Sub Level Object 1.

What happens, however, is that it is always added as the last object in the Sub Level Object list:
Top Level Object 2
        Sub Level Object 1
        Sub Level Object 2
        Sub Level Object 3
        Sub Level Object 4
        Top Level Object 1
Top Level Object 3
Top Level Object 4

Note that this is only occurring in the "real" object hierarchy, the NSTreeNodes reflect the correct hierarchy.

When I had a look at the backtraces it seems that NSTreeController eventually calls -addObject: on the children array, which of course adds the item to the end of the children.

Does anyone know why this is occurring? Is there a workaround, or am I doing something wrong?

--
Rob Keniger



_______________________________________________

Cocoa-dev mailing list ([email protected])

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to