I have an app where I'm trying to recursively load views. So I have one view (theViewController) that is able to drill down into another view of the same type (theViewController). I have the recursion working fine and the back buttons work just fine. But I'm trying to implement a function that does some work and then unloads the current view.
In another spot in my code I have the following:
MyAppDelegate *delegate = [[UIApplication sharedApplication] delegate];
UINavigationController *navigationController = [delegate navigationController];
[navigationController popViewControllerAnimated:YES];
It is also at the end of a function that does some work for that view (theSecondViewController), but it loads a different view (theViewController).
My problem is when I use this SAME code in my theViewController it breaks down. Well, kind of. I think it goes through and does pop the controller off, but when it tries to reload the view (theViewController) to the left of it (above it, however you want to think about it) it dies. Once in a blue moon it will spit out:
malloc: *** error for object 0xfb9640: double free
*** set a breakpoint in malloc_error_break to debug
But usually it just dies without errors (at least I think thats what this stuff is):
GNU gdb 6.3.50-20050815 (Apple version gdb-966) (Tue Mar 10 02:43:13 UTC 2009)
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB. Type "show warranty" for details.
This GDB was configured as "i386-apple-darwin".sharedlibrary apply-load-rules all
Attaching to process 15739.
Any help in understanding why it might die on reloading a page would be very helpful.
Update: If there was an error with the nib wouldn't an issue come up earlier? I believe that it is correct. I'm just not sure where the code is going after [navigationController popViewControllerAnimated:YES]; I thought it would go to the next view's viewDidLoad. But I have a NSLog message there and its not showing up.
The navigation I can do thus far is this:
userViewController -> theViewController -> ... -> theViewController -> theSecondViewController
If its straight in and straight out it works fine. The code above works in theSecondViewController but not theViewController