iPhone - testing if a notification exists

前端 未结 2 1534
感动是毒
感动是毒 2021-01-07 18:56

At some point in a code one may add something like

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(doSomething) name:@\"Hello\" obj         


        
2条回答
  •  离开以前
    2021-01-07 19:27

    Remove observer before adding it:

    How to avoid adding multiple NSNotification observer?

    For unit testing you should mock NSNotificationCenter as it is dependency.

提交回复
热议问题