• 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: One NSOutlineView, more than one identical items
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

  • Follow-Ups:
    • [SOLVED] Re: One NSOutlineView, more than one identical items
      • From: Nick Zitzmann <email@hidden>
References: 
 >Re: One NSOutlineView, more than one identical items (From: Nick Zitzmann <email@hidden>)

  • Prev by Date: Re: Still NSTextView custom insertion point
  • Next by Date: Re: create NSMutableString with no limit?
  • Previous by thread: Re: One NSOutlineView, more than one identical items
  • Next by thread: [SOLVED] Re: One NSOutlineView, more than one identical items
  • Index(es):
    • Date
    • Thread