Re: One NSOutlineView, more than one identical items
Re: One NSOutlineView, more than one identical items
- Subject: Re: One NSOutlineView, more than one identical items
- From: Greg Herlihy <email@hidden>
- Date: Sun, 19 Mar 2006 00:23:31 -0800
- Thread-topic: One NSOutlineView, more than one identical items
I would use proxy objects as stand-ins for the duplicate outline items. Each
proxy would be a unique object as far as the outline table is concerned, but
each would seem to be a duplicate of the original as far as the user is
concerned.
To get you started, I wrote (but did not test!) an all purpose proxy class
that should work for this purpose (hence its name):
@interface ProxyOutlineItem : NSProxy
{
id _realObject;
}
+ (id)proxyOutlineItemWithObject:(id)object;
- (id)initWithObject:(id)object;
- (void)forwardInvocation:(NSInvocation *)invocation;
- (NSMethodSignature *)methodSignatureForSelector:(SEL)sel;
- (id)realObject;
@end
@implementation ProxyOutlineItem
+proxyOutlineItemWithObject:(id)object
{
id proxy = [[ProxyOutlineItem alloc] initWithObject:object];
if (proxy == nil)
return nil;
return [proxy autorelease];
}
-(id)initWithObject:(id)object
{
// there is no init method in super to call here
_realObject = [object retain];
return self;
}
-(id)realObject
{
return _realObject;
}
- (NSMethodSignature *)methodSignatureForSelector:(SEL)sel
{
return [[self realObject] methodSignatureForSelector:sel];
}
- (void)forwardInvocation:(NSInvocation *)invocation
{
[invocation invokeWithTarget:[self realObject]];
}
-(void)dealloc
{
[_realObject release];
[super dealloc];
}
@end
Greg
On 3/18/06 7:28 PM, "Nick Zitzmann" <email@hidden> wrote:
>
> On Mar 17, 2006, at 9:35 PM, Shaun Wexler wrote:
>
>> It sounds like your model isn't really a tree structure. Probably
>> the best thing would be to use a lightweight tree class for the
>> items in all of your NSOutlineView data sources, where each node
>> has exactly one parent, and zero or more children.
>
> That's right; the model is not a tree and allows anything to be
> related to anything or nothing, except for circular relationships,
> which aren't allowed. But I was really hoping to avoid having to set
> up a double-model. Isn't there any way I can force NSOutlineView to
> accept multiple instances of the same item? I was hoping I could fix
> this in a subclass or something...
>
> Nick Zitzmann
> <http://www.chronosnet.com/>
>
> _______________________________________________
> 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
_______________________________________________
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