Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do i check whether my current navigationController.view = a classes.view? Reason = push notifications. + iphone

so basically in my app delegate i have a navigation.controller

This navigation controller has a view of a class named MainScreen.

In MainScreen.m , i have a IBAction which will bring me to a SelectionScreen.m page by pushing it. here is the coding for it

SelectionScreen *aSelectionScreenViewController = [[SelectionScreen alloc]initWithNibName:@"SelectionScreen" bundle:nil];
[self.navigationController pushViewController:aSelectionScreenViewController animated:YES];
[aSelectionScreenViewController release];

So how do i check if my current navigationController.view = this selectionscreen.view?

The reason for checking which current view it is, is because when i receieve a push notification, i would want to automatically switch to this SelectionScreen.m page and invoke some methods within it. But this checking can only be done in the appDelegate because the didReceiveRemoteNotification method is located in there.

like image 840
Kenneth Avatar asked Jan 21 '23 12:01

Kenneth


1 Answers

This is how i'm doing it

for example if you have three ViewControllers ,and any of those have possibility to be pushed by NavigationController:

ViewControllerA
ViewControllerB
ViewControllerC

Then what you need to do is:

-(void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo
{
    if ([[self.navigationController topViewController] isKindOfClass:[ViewControllerA class]]) {

    //do sth
    }

    if ([[self.navigationController topViewController] isKindOfClass:[ViewControllerB class]]) {

    //do sth
    }

    if ([[self.navigationController topViewController] isKindOfClass:[ViewControllerC class]]) {

    //do sth
    }

}//end of code
like image 198
X Sham Avatar answered Feb 28 '23 05:02

X Sham