Courses • Unity Assets • PlayStore • Hosting • Channel • بالعربي

Ahmad Naser Navigation
  • Home
    • Apps
    • Arabic Website
    • Our Academy
    • Udemy Courses
    • Certification
    • Youtube
    • Code Snippets
  • About
    • About Us
    • Services
    • Apps
    • Clients
    • Projects
    • Professional Training
  • Courses
  • My Account
  • Shop
    • Go Shopping
    • Online Coaching
    • One-To-One Training Pricing
    • Hosting
    • Cart
    • Checkout
  • Blog
  • Contact
  • 0 Items$0.00
  • Home
    • Apps
    • Arabic Website
    • Our Academy
    • Udemy Courses
    • Certification
    • Youtube
    • Code Snippets
  • About
    • About Us
    • Services
    • Apps
    • Clients
    • Projects
    • Professional Training
  • Courses
  • My Account
  • Shop
    • Go Shopping
    • Online Coaching
    • One-To-One Training Pricing
    • Hosting
    • Cart
    • Checkout
  • Blog
  • Contact
  • 0 Items$0.00
Home Gist NotificationCenter addObserver Swift
back to snippest | Comment | Share
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)