Using Notifications in Chatter

You are now ready to add notifications to Chatter. Here is the game plan you will follow for doing that: Each window controller will post a notification whenever the user sends a message. All of the window controllers will observe these notifications. When they observe one, they will update their text views to display the new message.

To begin, create two constant strings at the top of ChatWindowController.swift.

i​m​p​o​r​t​ ​C​o​c​o​a​

p​r​i​v​a​t​e​ ​l​e​t​ ​C​h​a​t​W​i​n​d​o​w​C​o​n​t​r​o​l​l​e​r​D​i​d​S​e​n​d​M​e​s​s​a​g​e​N​o​t​i​f​i​c​a​t​i​o​n​
 ​ ​ ​ ​=​ ​"​c​o​m​.​b​i​g​n​e​r​d​r​a​n​c​h​.​c​h​a​t​t​e​r​.​C​h​a​t​W​i​n​d​o​w​C​o​n​t​r​o​l​l​e​r​D​i​d​S​e​n​d​M​e​s​s​a​g​e​N​o​t​i​f​i​c​a​t​i​o​n​" ...

Get Cocoa Programming for OS X: The Big Nerd Ranch Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.