Checking the navigation controller stack

Discussion in 'iOS Development' started by johnmabassa, Jun 18, 2009.

  1. johnmabassa

    johnmabassa Member

    Joined:
    Mar 16, 2009
    Messages:
    87
    Likes Received:
    0
    Hi,

    Is there any way to check whether a particular view controller is already pushed into the navigation controller stack, so that I can prevent it from pushing into the stack again which might lead to crash of your application?


    -John
  2. wibble

    wibble New Member

    Joined:
    Mar 16, 2008
    Messages:
    176
    Likes Received:
    0
    gdb backtrace
  3. johnmabassa

    johnmabassa Member

    Joined:
    Mar 16, 2009
    Messages:
    87
    Likes Received:
    0
    I want to put some conditions like this

    say if viewController1 doesnot exist in navigationcontroller then only push it. Otherwise dont.

    -John
  4. johnmabassa

    johnmabassa Member

    Joined:
    Mar 16, 2009
    Messages:
    87
    Likes Received:
    0
    Guys,
    I have found the answer a couple of days back, sorry for posting it late
    Code:
    if([[navigationController  viewControllers] containsObject:myViewController])
    		{
    
    			[navigationController popToViewController:myViewController animated:YES];
    		}
    else
    {
    //Push it
    }
    I never stops my investigation until I finds my answer

    Please Register or Log in to view images


    -John

Share This Page