Adding observers

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

  1. grandM macrumors 65816


    Oct 14, 2013
    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?

  2. xStep macrumors 68000

    Jan 28, 2003
    Less lost in L.A.
    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