I have 4 child view controllers inside the tab bar, Let's assume I call a second view controller from child1. I have NotificationCenter.default.post here in this second VC which calls a function in child1 through notification center's add observer. The problem is, the add observer function in child1 is being called more than once.
I believe it has something to do with the other children (child2, child3, child4) since originally they all are using the same VC but with different data so the observer is present in all of them but I only want it to execute from the current child (in our example child1) that opens up the second VC. If child 2 opens up second VC, then the observer function should execute in child2 only.
I have tried storing the VC from which second VC gets opened but that doesn't seem to work as well.
I have 4 child view controllers inside the tab bar, Let's assume I call a second view controller from child1. I have NotificationCenter.default.post here in this second VC which calls a function in child1 through notification center's add observer. The problem is, the add observer function in child1 is being called more than once.
I believe it has something to do with the other children (child2, child3, child4) since originally they all are using the same VC but with different data so the observer is present in all of them but I only want it to execute from the current child (in our example child1) that opens up the second VC. If child 2 opens up second VC, then the observer function should execute in child2 only.
I have tried storing the VC from which second VC gets opened but that doesn't seem to work as well.
Any suggestions or how could I fix this?