NSNotificationCenter addObserver in Swift

Swift 4.0 & Xcode 9.0+: Send(Post) Notification: NotificationCenter.default.post(name: Notification.Name(“NotificationIdentifier”), object: nil) OR NotificationCenter.default.post(name: Notification.Name(“NotificationIdentifier”), object: nil, userInfo: [“Renish”:”Dadhaniya”]) Receive(Get) Notification: NotificationCenter.default.addObserver(self, selector: #selector(self.methodOfReceivedNotification(notification:)), name: Notification.Name(“NotificationIdentifier”), object: nil) Function-Method handler for received Notification: @objc func methodOfReceivedNotification(notification: Notification) {} Swift 3.0 & Xcode 8.0+: Send(Post) Notification: NotificationCenter.default.post(name: Notification.Name(“NotificationIdentifier”), object: nil) Receive(Get) Notification: NotificationCenter.default.addObserver(self, selector: #selector(YourClassName.methodOfReceivedNotification(notification:)), name: Notification.Name(“NotificationIdentifier”), … Read more

Send and receive messages through NSNotificationCenter in Objective-C?

@implementation TestClass – (void) dealloc { // If you don’t remove yourself as an observer, the Notification Center // will continue to try and send notification objects to the deallocated // object. [[NSNotificationCenter defaultCenter] removeObserver:self]; [super dealloc]; } – (id) init { self = [super init]; if (!self) return nil; // Add this instance of … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)