This solution is very clumsy, but it appears to work…
dynamic var userName: String?
@IBAction func send(sender: AnyObject) {
sender.window?.endEditingFor(nil)
if var message = message {
if (self.userName != nil) {
message = (self.userName! + ": " + message)
}
else {
message = ("Default User: " + message)
}
let userInfo = [ChatWindowControllerMessageKey : message]
let notificationCenter = NSNotificationCenter.defaultCenter()
notificationCenter.postNotificationName(ChatWindowControllerDidSendMessageNotification, object: self, userInfo: userInfo)
}
message = ""
}