Adding observers

Discussion in 'iOS Programming' started by grandM, Sep 6, 2018.

  1. grandM macrumors 6502a

    grandM

    Joined:
    Oct 14, 2013
    #1
    Hi there

    I'm adding an observer to NotifationCenter in a tab of a tab bar controller. At the moment this observer is added in viewDidLoad(). This implies I first need to open that tab to put the observer on it. Does anyone know a way to add that observer without having the tab opened before?

    Thanks
     
  2. xStep macrumors 68000

    Joined:
    Jan 28, 2003
    Location:
    Less lost in L.A.
    #2
    The obvious place is in the appropriate init method. Read the docs to understand which one gets called in your scenario.

    Remember that you can’t access the UI elements until viewDidLoad gets executed.
     

Share This Page