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

poke

macrumors newbie
Original poster
May 18, 2012
2
0
Hi,

i have a method called perform4 in the ViewController.m

Code:
-(void) perform4
{
 NSLog(@"perform4");
 UIStoryboard *mainStoryBoard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil];
ViewController4 *view4 = (ViewController4 *) [mainStoryBoard instantiateViewControllerWithIdentifier:@"ViewController4"];

[self.view removeFromSuperview];
[self release];

self.view = view4.view;
[self release];
}

this Method has to be called from my AppDelegate.m with this AlertView Button

Code:
-(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
 if(buttonIndex==0)
{
   NSLog(@"Button 0");

  
  //EVERYTHING I WILL PUT HERE DO NOT WORK OR MAKE A CRASH :/
  //like
  // ViewController *view1 = [[ViewController alloc]init];
  // [view1 perform4];
  // WHY DO THIS DONT WORK? 

}

Thanks
 
it works, when i call it from the viewcontroller.m , but not when i try to call it from the appdelegate.m - i need to know how to call it, to make everything work :(

can you help me please?


ok i realized this with

Code:
self.window.rootViewController.view = view4;
[self.window makeKeyAndVisible];

but i have now the problem to switch back, while

Code:
self.window.rootViewController.view = view;
[self.window makeKeyAndVisible];

let crash my app :(
 
Crash

Are you sure you should be calling [self release]? Twice?

That seems very bad. If you try to switch back to this view it will crash because the view controller has been improperly deallocated.
 
In Xcode, click on the menu "Product" in the menubar. Select the item "Edit Scheme". Under "Diagnostics", you should have "Enable Zombie Objects" checked off. If you do this, you will receive a warning whenever an object that has been dealloced is sent a message. (either because you released too often, as I suspect you did, or because you didn't retain as often as you should have.)
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.