在我的 Objective-C 类中,我添加了以下代码
[[NSNotificationCenter defaultCenter] postNotificationName:@"Notify" object:nil];
在我的 Swift 类中,我添加了以下代码
NotificationCenter.defaultCenter().addObserver(self, selector:(DataProcessingMethod), name:@"" , object: nil)
但不幸的是不起作用,代码有什么问题?
最佳答案
应该是这样的:
NotificationCenter.default.addObserver(self, selector: #selector(DataProcessingMethod), name: NSNotification.Name(rawValue: "Notify"), object: nil)
关于ios - swift 类和 Objective -c Viewcontrollers 之间的通知中心网络,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42415872/