Search This Blog

Thứ Hai, 11 tháng 12, 2017

Truyen tham so NotificationCenter in IOS


// khoi tao 
NotificationCenter.default.addObserver(self, selector: #selectorself.gotoSelectCate( not: ) ), name: NSNotification.Name(rawValue: "gotoSelectCate"), object: nil)




func gotoSelectCate( not: NSNotification ){
        
        if let userInfo = not.userInfo {
            
            if let userName = userInfo["name"] as? String {
                print(userName)
                scrollToCateSelected(md: arrList[Int(userName)!] as! ModelCate)
            }
        }
        self.slideMenuController()?.closeLeft()
        

 }

// class khac 

NotificationCenter.default.post(name: NSNotification.Name(rawValue: "gotoSelectCate"), object: self , userInfo: ["name": mdGet.m_type ] )

Không có nhận xét nào:

Đăng nhận xét