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: Keith Wilson <email@hidden>
- Date: Sat, 18 Mar 2006 16:01:46 +1100
Hi Nick,
The same object may be displayed in an outlineView many times.
Are you sure you are interpreting the word "item" correctly?
If not sure, then have a look at Examples/Appkit/OutlineView.
Keith
On 18/03/2006, at 3:35 PM, Shaun Wexler wrote:
On Mar 17, 2006, at 3:32 PM, Nick Zitzmann wrote:
I realize that in the NSOutlineView documentation, it says that
the view "requires that each item in the outline view be unique."
But my model may include multiple items that are exactly the same.
Are there any ways I can get one NSOutlineView instance to
correctly work with multiple instances of the same item being
visible at once? If so, then what do I have to do to get this to
work without leaking lots of memory or creating a second model
filled with wrappers from the first model? I'm really not looking
forward to having to wrap everything in a second model. Right now,
when this case comes up, the worst I'm seeing is some redrawing
glitches, but I have a feeling something worse could happen...
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. You can size
and cache-align your items for efficiency (create a separate zone
and write an object allocator which returns modulo-32-byte
blocks). Example wrapper:
@interface OutlineViewItem : NSObject <NSCoding, NSCopying>
{
int refcount;
int flags;
id object;
id parent;
NSMutableArray *children;
NSString *name;
NSImage *image;
}
+ (id)allocWithZone:(NSZone *)zone; // custom allocator
- (id)copyWithZone:(NSZone *)zone;
- (id)initWithCoder:(NSCoder *)decoder;
- (void)encodeWithCoder:(NSCoder *)encoder;
- (id)retain;
- (void)release;
- (int)refCount;
- (BOOL)isLeaf;
- (BOOL)isExpandable;
- (BOOL)enabled;
- (void)setEnabled:(BOOL)enabled;
- (id)representedObject;
- (void)setRepresentedObject:(id)value;
- (id)parent;
- (void)setParent:(id)value;
- (NSMutableArray *)children;
// ...
--
Shaun Wexler
MacFOH
http://www.macfoh.com
"Intellectuals solve problems, geniuses prevent them." - Albert
Einstein
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
40bigpond.net.au
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