On 23 Aug 2008, at 12:58 am, Paul Bruneau wrote:

I think I could maybe (maybe!) figure out how do this for the order (the table's selection), but I am totally lost as to how I would do it for the order's great-grandchildren order steps.


Data structure?

Does an order keep a list of its children? And those objects keep a list of their children and so on? Then just propagate "needs display" change to the children, then they'll do the same, and so on. Usually these will all be objects of the same class, or share some common subclass, or at least have certain methods in common. You have to arrange all of this.

So let's say you have this:

// MyObject.h

@interface MyObject : NSObject
{
  NSArray*         myChildren;
  NSView*          myViewRef;
  NSRect           myBounds;
}

- (void) flagChanged;

@end

//MyObject.m

@implementation MyObject

- (void) flagChanged
{
    [myViewRef setNeedsDisplayInRect:myBounds];
[myChildren makeObjectsPerformSelector:@selector(flagChanged)]; // <-- will call flagChanged on every child object, which recurses in turn
}


@end

Now assuming that these objects are all linked together correctly in a nice tree structure, sending -flagChanged to the root object will propagate that change down to every child and every child's child, and so on.

This is very conceptual, but may help - does it?

Note that this assumes that if you are modelling something that is structured as a tree or hierarchy in real life, you've implemented it as a tree or hierarchy in your code. Normally this is what you would do!

cheers, Graham


_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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