How to set addObserver in SwiftUI?

前端 未结 6 2158
眼角桃花
眼角桃花 2021-02-13 16:35

How do I add NotificationCenter.default.addObserve in SwiftUI?

When I tried adding observer I get below error

Argument of \'#sele

6条回答
  •  爱一瞬间的悲伤
    2021-02-13 17:35

    exchange this

    self.NC.addObserver(self, selector: #selector(self.VPNDidChangeStatus),
                              name: .NEVPNStatusDidChange, object: nil) 
    

    to

    self.NC.addObserver(self, selector: #selector(VPNDidChangeStatus(_:)),
                              name: .NEVPNStatusDidChange, object: nil)
    

提交回复
热议问题