How to readd a notification observer

So I have about four notification observers added in a particular view controller, but I want to remove one in particular if a condition is met and then add it back for a different condition. I was able to remove the particular observer but I have had trouble adding it back. the other ones work except the one a removed and added back and I know it's working cos when the VC loads and all the notification observers are added but then it stops working after adding it back. here's my code:

registered the observer in ViewDIdAppear and this registers my Bluetooth device and whenever I tap on the Bluetooth device button this function gets called
Code Block
NotificationCenter.default.addObserver(
self, selector: #selector(Myclass.deviceTapped), name: Notification.Name("bluetoothRecievedNoticicationName"), object: nil)


I removed the observer here
Code Block
if removeOberver == true {
NotificationCenter.default.removeObserver(self, name: Notification.Name("bluetoothRecievedNoticicationName"), object: nil)
}

and then use this to add it back again
Code Block
if removeOberver == false {
NotificationCenter.default.addObserver(
self, selector: #selector(Myclass.deviceTapped), name: Notification.Name("bluetoothRecievedNoticicationName"), object: nil)
}

and after adding this ^ back, the deviceTapped function doesn't get called anymore

Where do you reset removeOberver to false ?

Are you sure this is even executed ?
Add a log:

Code Block
if removeOberver == false {
print("Re-add notification")
NotificationCenter.default.addObserver(
self, selector: #selector(Myclass.deviceTapped), name: Notification.Name("bluetoothRecievedNoticicationName"), object: nil)
}

Note: may be there is a typo in bluetoothRecievedNoticicationName (bluetoothRecievedNotificationName)
It is in fact a better practice to define name in extension:

Code Block
extension Notification.Name { 
    public static let kBTReceiveNotification = Notification.Name("bluetoothRecievedNotificationName")
}

How to readd a notification observer
 
 
Q