Hey Wave,

Is the Sequence delegate interested in all Element/Markers moved into and out of? Or only some small subset?

If the former, you really just want something like:

NSNotificationCenter* ctr = [NSNotificationCenter defaultCenter];
SEL s = @selector(enteredElement:);
[ctr addObserver:delegate selector:s name:XXTimeMovedForward object:sequence];

and then make the Sequence include the element/marker info as part of the notification user info:

NSDictionary *info = [NSDictionary dictionaryWithObjectsAndKeys:markerArray, @"XXMarkers", element, @"XXElement", nil]; [[NSNotificationCenter defaultCenter] postNotificationName:XXTimeMovedForward object:self userInfo:info];

The delegate then examines the user info of the notification it receives to get the list of Markers that got entered and the Element entered (if any).

If your delegates don't want to see all those notifications and are only interested in a small subset of the Elements/Markers, then you'll probably want to have your Sequence have its own notification center, and have delegates sign up with that center to get notified of Elements/Markers. Multiple Sequences then have different centers, which would support having the same marker or element in more than one sequence (you didn't mention if this was a requirement or not, but it wouldn't be a problem)...

Delegate then looks like:

NSNotificationCenter* ctr = [sequence notificationCenter];
SEL s = @selector(enteredElement:);
[ctr addObserver:delegate selector:s name:XXTimeMovedForward object:elementInterestedIn];

and the notifications can just be sent from the Sequence via:

[[self notificationCenter] postNotificationName:XXTimeMovedForward object:elementMovedInto];

Hope this helps!

        - Greg


You'll probably want to have your Sequence have its own


On Jan 8, 2009, at 2:59 PM, Michael B Johnson wrote:

So I have a "Sequence" of "Elements", ordered by "Time". Elements cannot overlap each other, they can only be strung in a temporal line, with no gaps (i.e. the end of one element abuts another, unless its at the front or end).

In addition to these Elements, we can drop "Markers" on this sequence, where the Markers can be attached to a single point in Time, or some contiguous range of Time. Multiple Markers could be on the same point in Time, or overlap each other in Time.

Let's say Time can move forward, move backwards, or instantaneously jump to a point in Time.

This Sequence has a delegate, that would like to express interest in the following:

(1) when the "current time" moves forward into the beginning of an Element or Marker. (2) when the "current time" moves backward into the end of an Element or Marker. (3) when the "current time" is the same as a Marker attached to a single point in time.

With that information, we would know what Element is "active", and what Markers might be "active".

So what info do we need? Assuming a Sequence has some delegate, that delegate could register the Sequence to be told when any of those three events happens.

Let's say we use as our unique identifier the following info in a dictionary:

- sequence
- time value
- time direction (forward, backwards, impulse (i.e. neither, it just appeared there))
- object (i.e. Element or Marker that this Time value concerns

so the delegate registers to get notifications from the sequence by (and this is where the pattern is weird):

NSNotificationCenter* ctr = [NSNotificationCenter defaultCenter];
SEL s = @selector(enteredElement:);
NSDictionary* dict = [NSDictionary dictionaryWithObjectsAndKeys:sequence, @"XXSequence", time, @"XXTimeValue", direction, @"XXTimeDirection", element, @"XXElement", nil]; [ctr addObserver:delegate selector:s name:XXTimeMovedForward object:dict];

what's weird about this is that we're handing in a *dictionary* that contains the object that will send out this notification, not the object itself.

That's weird, right? But you see what I'm trying to do? Is there some other pattern here I'm missing?

Thanks in advance for any help.


--> Michael B. Johnson, PhD
--> http://homepage.mac.com/drwave (personal)
--> http://xenia.media.mit.edu/~wave (alum)
--> MPG Lead
--> Pixar Animation Studios

_______________________________________________

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/greg%40omnigroup.com

This email sent to g...@omnigroup.com

_______________________________________________

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 arch...@mail-archive.com

Reply via email to