I have written the sending notification in one view and receiving on another view but it is not working. I have followed the code from NSNotificationCenter addObserver in Swift but couldn't make it, any suggestion will really be grateful
Here is my code
ViewController 1 or sending notification view
import UIKit
class HomeView: UIViewController {
@IBOutlet weak var subscribers: CustomButton!
@IBOutlet weak var newResig: CustomButton!
override func viewDidLoad() {
}
override func viewWillDisappear(animated: Bool) {
}
@IBAction func languageEnglish(sender: AnyObject) {
subscribers.setTitle("SUBSCRIBERS", forState: .Normal)
newResig.setTitle("NEW REGISTRATION", forState: .Normal)
}
@IBAction func languageArabic(sender: AnyObject) {
subscribers.setTitle("المشتركين", forState: .Normal)
newResig.setTitle("اشتراك جديد", forState: .Normal)
NSNotificationCenter.defaultCenter().postNotificationName("NotificationIdentifier", object: nil)
}
}
ViewController 2 or receiving notification view
import UIKit
class Subscription: UIViewController {
@IBOutlet weak var scheduling_Appointment: UILabel!
@IBOutlet weak var deliveryMedicine: UILabel!
@IBOutlet weak var visitDoc: UILabel!
@IBOutlet weak var medicalHelp: UILabel!
@IBOutlet weak var ChronicDiseases: UILabel!
@IBOutlet weak var contactUs: UILabel!
override func viewDidLoad() {
self.title = "Subscribers"
self.navigationController?.navigationBar.tintColor = UIColor.whiteColor()
NSNotificationCenter.defaultCenter().addObserver(self, selector: #selector(Subscription.methodOfReceivedNotification(_:)), name:"NotificationIdentifier", object: nil)
}
func methodOfReceivedNotification(notification: NSNotification){
//Take Action on Notification
scheduling_Appointment.text = "حجز كشف جديد"
deliveryMedicine.text = "توصيل الادوي"
visitDoc.text = " زيارة الاطباء"
medicalHelp.text = "التحدث المباشر"
ChronicDiseases.text = "الامراض المزمنة"
contactUs.text = "اتصل بنا"
}
}