#7 Understanding notifications (part 2)
In this Episode, I will illustrate how an observer object can listen to notifications sent by a particular object. I assume you have already watched Episode #6.
- Download .mov file (32.8 MB, 5:45)
- Download .m4v file for iPod & Apple TV (11.4 MB, 5:45)
- This episode on Vimeo (HD quality)
- Full episode source code
As always, feel free to give some feedback about this episode!


Good stuff. Thank you for taking the time to do this
Can’t wait for the rails with cappuccino stuff.
Hi Thomas,
I’m a cappuccino newbie (I discovered it earlier this morning) and after watching this screencast I have a question for you:
Instead creating two methods (createNewWindowLinkedToLeftSlider and createNewWindowLinkedToRightSlider) that both call createNewWindow with a different parameter, is not possible to call directly createNewWindow in setAction ( [right_button setAction:@selector(createNewWindow ...)] ; )?
Thanks
@Sig : Hi, action messages always take a single argument, which is the object that sent the message, so you can’t pass other arguments. You can read more about the target-action pattern here : http://developer.apple.com/mac/library/documentation/cocoa/conceptual/ObjectiveC/Articles/ocSelectors.html#//apple_ref/doc/uid/TP30001163-CH23-TPXREF132
What I could have done was to declare button and right_button as 2 ivars, then set their action to @selector(createNewWindow:), and implement createNewWindow like this
- (void)createNewWindow:(id)sender
{
if (sender===button)
// …
else // sender===right_button
// …
}
Hope this helps,
Thomas.