发送通知
let dic = ["name":"hello"];
NSNotificationCenter.defaultCenter().postNotificationName("NotificationIdentifier",object: dic)
接收通知
NSNotificationCenter.defaultCenter().addObserver(self,selector: "getMyName:",name:"NotificationIdentifier",object: nil)
NSNotificationCenter.defaultCenter().removeObserver(self,name: "NotificationIdentifier",object: nil)
NSNotificationCenter.defaultCenter().removeObserver(self)
func getMyName(notification:NSNotification){
//获取词典中的值
let name = notification.object?.valueForKey("name") as? String
//通知的名称
let nameNotification = notification.name
//notification.userInfo 接收object 对象 一些信息 例如入键盘的一些信息
print(nameNotification)
print(name);
}