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.

import Cocoa

private let ChatWindowControllerDidSendMessageNotification
    = "com.bignerdranch.chatter.ChatWindowControllerDidSendMessageNotification"
private let ChatWindowControllerMessageKey
    = "com.bignerdranch.chatter.ChatWindowControllerMessageKey" class ChatWindowController: NSWindowController ...

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.