How to get pointer to object

Discussion in 'iOS Programming' started by svjim, Sep 16, 2008.

  1. svjim macrumors newbie

    Joined:
    Aug 27, 2008
    #1
    I am building an UITabBar application using interface builder. The application has 3 tabs on it. The first tab is tied to a UIView and database and its sole purpose is to add data to the database. The second tab is a UITableView and its purpose in life is to display the data in the database. The third tab displays a graph of the data.

    My issue concerns the UITableView and how to send it a message to reload it self from the first view which knows nothing of the tableview but does know when it has updated the database. So my question is how do a I get a pointer to the UITableView in the UIView so I can send the reloaddata message to the UITableView?

    Thanks Jim
     
  2. PhoneyDeveloper macrumors 68030

    PhoneyDeveloper

    Joined:
    Sep 2, 2008
    #2
    Various ways.

    I might prefer to do this with NSNotification/NSNotificationCenter. Have the database viewcontroller post a notification when the db is changed and have the tableviewcontroller register for that same notification.

    Otherwise whatever controller creates the tabs, probably your app delegate, should pass the necessary information to the db viewController about the tableviewcontroller when they're created.
     
  3. svjim thread starter macrumors newbie

    Joined:
    Aug 27, 2008
    #3
    NSNotificationCenter

    Thanks, that did the trick. It took a bit to get the syntax correct as I was looking at a Mac OSX example and the code is slightly different. In the end, it was amazingly simple.

    Jim
     

Share This Page