Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Howiieque

macrumors regular
Original poster
Feb 1, 2009
120
0
hello
i encountered a problem.

RootViewController:A
SecondViewController:B

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.
 
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
Code:
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.
 
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

Code:
if (! (value))
{
     NSLog(message);
     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.
 
thank you very much.
i did use something that i did not fully understand.
i didn't know it will terminate the thread.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.