I have two containers in a view. The top one has a collection view. I want to update my collection view from a button when a button is hit from the below container. My butto
I have added
NSNotificationCenter.defaultCenter().addObserver(self, selector: "loadList:", name:"load", object: nil)
in my viewdidload of my collection view class. also added a selector which reloads my data when it is called by the Notification Center
func loadList(notification: NSNotification){
self.favoritesCV.reloadData()
}
and for the other class where the button is pressed:
NSNotificationCenter.defaultCenter().postNotificationName("load", object: nil)
Swift 3:
NotificationCenter.default.addObserver(self, selector: #selector(loadList), name:NSNotification.Name(rawValue: "load"), object: nil)
NotificationCenter.default.post(name: NSNotification.Name(rawValue: "load"), object: nil)