OC Swift NotificationCenter通知

NotificationCenter.default.addObserver(self, selector: #selector(sendAddCategory), name: NSNotification.Name(rawValue: "SendAddCategory"), object: nil)`

@objc func sendAddCategory(notification:Notification){ let userInfo = notification.userInfo as! [String: AnyObject] let catagoryStr = userInfo["categoryStr"] as! String let catagoryId = userInfo["categoryId"] as! NSNumber }

[[NSNotificationCenter defaultCenter] postNotificationName:@"SendAddCategory" object:nil userInfo:@{@"categoryStr":categoryStr,@"categoryId" : [NSNumber numberWithInteger:categoryId]}];

你可能感兴趣的:(OC编程,Swift)