How to stop the Observer in NSNotification to called twice?

前端 未结 7 1169
被撕碎了的回忆
被撕碎了的回忆 2020-12-02 20:08

I have an observer of NSNotification which is called twice. I do not know what to do with it.

I googled it but no solution found.

[[NSNo         


        
7条回答
  •  萌比男神i
    2020-12-02 20:20

    Try to removeObserver in viewWillDisappear method :

    -(void)viewWillDisappear:(BOOL)animated{
    
    [[NSNotificationCenter defaultCenter] removeObserver:self name:@"startAnimating" object:nil]; }
    

提交回复
热议问题