Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6073257
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T10:15:05+00:00 2026-05-23T10:15:05+00:00

Hope you can help me with this problem. I am having issues with the

  • 0

Hope you can help me with this problem.
I am having issues with the following code:

-(IBAction)swapViews:(id)sender{
    myappAppDelegate *delegate = (myappAppDelegate *) [[UIApplication sharedApplication] delegate];
    ThirdViewController *thirdView = [[ThirdViewController alloc] initWithNibName:@"ThirdViewController" bundle:nil];
    [delegate switchView:self.view toView:thirdView.view];
    [thirdView release];
}

As you can see I allocated my ViewController and released it afterwards. The problem is that when i change views to my ThirdViewController and then want to get back to the previous view, the app crashes.
This is how i get back to my previous view:

-(IBAction)goBack:(id)sender{
    myappAppDelegate *delegate = (myappAppDelegate *) [[UIApplication sharedApplication] delegate];
    FirstViewController *firstView = [[FirstViewController alloc] initWithNibName:@"FirstViewController" bundle:nil];
    [delegate switchView2:self.view toView:firstView.view];
    [firstView release];
}

Again the same problem when releasing the View.
If I don’t release the views the app won’t crash but there are lots of memory leaks and taking into account I have over 15 ViewControllers, the app will eventually crash if I use it for a long time.

Any ideas what am I doing wrong?
ps: I am using a delegate for the animation/transition of the view.

Thanks!

Edit: switchView:toView: code below

-(void)switchView:(UIView *)view1 toView:(UIView *)view2 {
    [UIView beginAnimations:@"Animation" context:nil];
    [UIView setAnimationDuration:0.75];
    [UIViewsetAnimationTransition:UIViewAnimationTransitionCurlUp forView:self.window cache:YES];
    [view1 removeFromSuperview];
    [window addSubview:view2];
    [UIView commitAnimations];

}

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T10:15:05+00:00Added an answer on May 23, 2026 at 10:15 am

    Don’t want to sound like Mr. Obvious, but unless the view switched to is being retained in your delegate before its controller is released, you’re operating on a released view before switching back, hence the crash.

    It would be probably better if your switchView:toView methods operated on UIViewControllers, not just UIViews. Then you can retain the viewController whose view you need, and release it when it’s not needed any more.

    But for now that’s all we can take from your current problem description. Show the code of switchView:toView: and switchView2:toView: methods, and the crash log and we’ll go from there.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I hope that someone can help me with this problem that I've been having
I hope you can help me with this problem. What I intend to do:
I hope there's a SharePoint expert here on SO who can help with this.
I hope someone can help here, we're having an incredibly annoying time with Visual
HI, I hope somebody can help me here with the extjs framework. The problem
I'm having some problems with my stored procedure. Hope anyone can help me figure
hope you can help me with this: I'm working with j_security_check and have this
I hope you can help me with a problem; first, please don't worry about
My question really has three related parts which I hope you can help me
Hope anyone can shed light on this so I can use pens with dash

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.