queer behaviour of Navigation Bar: fails to navigate back

Discussion in 'iOS Programming' started by Howiieque, Dec 28, 2009.

  1. Howiieque macrumors regular

    Feb 1, 2009
    i encountered a problem.


    From A, i could succeed in navigating to B. In B, when i hit the back button, the navigation bar did changed back. but the B's view still there. Could anyone figure it out the reason or give some suggestions?

    there is no error message in the console, no crash.
  2. Howiieque thread starter macrumors regular

    Feb 1, 2009
    sorry for the vague and poor description a couple hours before. but that was as far as i could described it.

    after spending quite a few hours, i tracked the bug eventually. i wrote a statement
    NSAssert(NO, @"did appear");
    in the viewDidAppear in the view controller being pushed.

    though i succeeded in debugging the app, i am confused. why i could not do that. i think it is something like a NSLog(). i always saw others using it.

    could some one explain it a bit.
  3. PhoneyDeveloper macrumors 68040


    Sep 2, 2008
    NSAssert(value, message) is a macro that tests its value and then throws an exception if the value is false. In pseudocode it's something like this

    if (! (value))
         throw an exception;
    All those nasty messages from the system that result in some text in the debugger console and your app being terminated come from NSAssert usage in the framework.

    Normal usage of NSAsssert is to check what can be called invariants. Your invariants are expressions that MUST be true for the code to continue. This can be very useful while debugging but of course you need to understand that an invariant check has failed when that occurs.

    In your case you set the value to false so it would always fail and always throw an exception and terminate your app.
  4. Howiieque thread starter macrumors regular

    Feb 1, 2009
    thank you very much.
    i did use something that i did not fully understand.
    i didn't know it will terminate the thread.

Share This Page