title: Object was probably modified after being freed
body: <p>I am working on a project on iPhone. I am now initiating a new UIViewController from another UIViewController, and then switch between them. Here is my code.</p>
  
  <pre><code>iGreenAppDelegate *delegate = [UIApplication sharedApplication].delegate;
  if(checkInViewController) {
      [checkInViewController release];
      checkInViewController = nil;
  }
  checkInViewController = [[CheckInViewController alloc] initWithCheckpoint:checkpoint];
  
  [UIView beginAnimations:nil context:nil];
  [UIView setAnimationDuration:0.8];
  [UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:[delegate window] cache:YES];
  [[delegate rootTabBarController].view removeFromSuperview];
  [[delegate window] addSubview:checkInViewController.view];
  [UIView commitAnimations];
  </code></pre>
  
  <p>The Problem is the second time I initiate the UIViewController, I want to release it to avoid causing memory leak. The Debugger displays</p>
  
  <blockquote>
    <p>iGreen(916,0x3f60348c) malloc:  error for object 0x130350: incorrect checksum for freed object - object was probably modified after being freed.
     set a breakpoint in malloc_error_break to debug</p>
  </blockquote>
  
  <p>This is strange because similar codes in other parts don't return such error. Moreover, I tried autorelease, but the program will immediately crash and the Debugger says I am modifying finalized layers.</p>
  
  <p>I've been working on the problem for a whole night, and still confused about it.</p>