1 2 3 4 5 6 7 8 9 10 11 12 |
import Foundation class API { static let shared = API() func selectCategory(userInfo : [String:Any]) { NotificationCenter.default.post(name: .didSelectCategory, object: self, userInfo: userInfo) } } |
1 2 3 4 5 |
import Foundation extension Notification.Name { static let didSelectCategory = Notification.Name("didSelectCategory") } |
1 |
NotificationCenter.default.addObserver(self, selector: #selector(didSelectCategory(_:)), name: .didSelectCategory, object: API.shared) |
1 2 3 4 5 6 7 8 9 10 |
@objc func didSelectCategory(_ notification : Notification) { let data = notification.userInfo as! [String : Any] lblCategoryName.text = data["catName"] as! String catID = data["catID"] as! Int print(catID) } |
1 2 3 4 5 |
let data : [String : Any] = [ "catName" : section.selectedRow()?.value ?? "Nothing is selected", "catID" : 1 ] API.shared.selectDays(userInfo: data) |