Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6083249
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T11:22:50+00:00 2026-05-23T11:22:50+00:00

I need to reload the data in a view controller when it’s tabbar is

  • 0

I need to reload the data in a view controller when it’s tabbar is clicked.

I am using the UITabBarControllerDelegate method as below:

- (void)tabBarController:(UITabBarController *)tabBarController didSelectViewController:(UIViewController *)viewController
{
    if (tabBarController.selectedIndex == 3) 
    {
        [(SomeViewController *)viewController getData];
    }
}

where ‘getData’ is an instance method in SomeViewController class. However when I run my app, I get the following error

2011-07-01 02:12:11.193 onethingaday[19169:207] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UINavigationController getData]: unrecognized selector sent to instance 0x600d500'

Can anyone advise me how I can overcome this issue? I just need to trigger the ‘getData’ method when tabbarcontroller.selected index ==3

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T11:22:51+00:00Added an answer on May 23, 2026 at 11:22 am

    It seems to me from the error message you get, that you use a UINavigationController in your tab controller; in this case, you cannot send directly the getData message to it; you should first find out which view controller under the UINavigationController should receive that message. (This is not actually related to the tab bar selectedIndex)

    I don’t know how your UINavigationController is organized, but you could do:

     - (void)tabBarController:(UITabBarController *)tabBarController didSelectViewController:(UIViewController *)viewController {
         if (tabBarController.selectedIndex == 3) {
    
       //-- option 1: getData goes to the first view controller in the UINavigationController:
             [[(SomeViewController*)[(UINavigationController*)viewController topViewController] getData];
    
       //-- option 2: getData goes to the last view controller in the UINavigationController (the visible one):
             [[(SomeViewController*)[(UINavigationController*)viewController visibleViewController] getData];
    
         }
     }
    

    If you give more details about the organization of your UINavigationController I can help further identifying the right option.

    Anyway, as you can see from the casts, there is something that is not fully ok with your design. I would strongly suggest using a notification for that. I.e., your SomeViewController registers itself for a notification of a given type :

     [[NSNotificationCenter defaultCenter] addObserver:self 
                                 selector:@selector(someSelector:) 
                                 name:ShouldGetDataNotification 
                                 object:nil];
    

    and the tab bar controller sends the notification for your controller to react upon:

     - (void)tabBarController:(UITabBarController *)tabBarController didSelectViewController:(UIViewController *)viewController {
         if (tabBarController.selectedIndex == 3) {
    
          [[NSNotificationCenter defaultCenter] postNotificationName:ShouldGetDataNotification object:nil];
         }
      ....
    }
    

    Look at this post.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In my root view controller, in my didReceiveMemoryWarning method, I go through a couple
I am using multiple view controllers associated with a corresponding tab. I need to
How do I dynamically reload the app.config in a .net Windows application? I need
I am using iPhone SDK 3.1.3. I have a UITableViewController which gets data from
I have one detail view controller in splitView - SearchDeatilViewController. But that view controller
I am getting leaks in Master view controller of iPhone. When I call this
I am having single table view in a view controller. That table view lists
Controller: public ActionResult Index() { // not using the interface right now DealsRepository _repo
I have developed a core data model for my application. I need to display
We're using a lot of YUI data tables to display data, and rather than

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.