What's the most cocoa-ey pattern for this?
What's the most cocoa-ey pattern for this?
- Subject: What's the most cocoa-ey pattern for this?
- From: Michael B Johnson <email@hidden>
- Date: Thu, 8 Jan 2009 14:59:56 -0800
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 (email@hidden)
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:
This email sent to email@hidden