0

I have an iPhone application in which I am testing in the applicationDidBecomeActive: that if the selected viewcontroller's rootview is there, then I want to call one webservice, otherwise not when I am coming from background to foreground I am taking the stack and checking it. But now even if I am in the rootview the webservice is not getting called. Can anybody help me on this?

Here is my code snippet:

- (void)applicationDidBecomeActive:(UIApplication *)application{
    NSLog(@"applicationWilssnd");
    if(tabBarController.selectedIndex==0)
    {

        NSArray *mycontrollers = self.tabBarController.viewControllers;
        NSLog(@"%@",mycontrollers);
        ///if([mycontrollers objectAtIndex:0]!=)
        ///[[mycontrollers objectAtIndex:0] popToRootViewControllerAnimated:NO];
        PinBoardViewController *pinvc=(PinBoardViewController*)[[mycontrollers objectAtIndex:0]topViewController] ;
        if([mycontrollers objectAtIndex:0]!=pinvc)
        {

        }
        else
        {
        [pinvc merchantnews];
        }
        mycontrollers = nil; 

      tabBarController.selectedIndex = 0;  

    }


}

`here the merchantnews is not getting called.

Adam B
  • 3,775
  • 3
  • 32
  • 42
hacker
  • 8,919
  • 12
  • 62
  • 108
  • @iPhoneDeveloper That's wrong, please look at the documentation to verify what you post before you spread confusion. – fzwo Aug 09 '12 at 07:14
  • Sorry for the haphazard answer.Check this link for now: http://stackoverflow.com/questions/3712979/applicationwillenterforeground-vs-applicationdidbecomeactive-applicationwillre – Tripti Kumar Aug 09 '12 at 07:17

1 Answers1

1
    PinBoardViewController *pinvc=(PinBoardViewController*)[[mycontrollers objectAtIndex:0]topViewController] ;
    if([mycontrollers objectAtIndex:0]!=pinvc)

Instead of this, try this

   PinBoardViewController *pinvc=(PinBoardViewController*)[[mycontrollers objectAtIndex:0]topViewController] ;
   if(pinvc isKindOfClass:[PinBoardViewController class]){
    // Do ur stuff
   }
hacker
  • 8,919
  • 12
  • 62
  • 108
DivineDesert
  • 6,924
  • 1
  • 29
  • 61