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 6391579
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T03:41:21+00:00 2026-05-25T03:41:21+00:00

I made a multiview app based on this Tutorial .Here is my code in

  • 0

I made a multiview app based on this Tutorial.Here is my code in the appdelegate.h

@class Disclaimerviewcontroller;

@interface GAINSAppDelegate : NSObject <UIApplicationDelegate> {
    Disclaimerviewcontroller *firstview;

}

@property (nonatomic, retain) IBOutlet UIWindow *window;
@property (nonatomic, retain )Disclaimerviewcontroller *firstview;

-(void)switchview :(UIView *)view1 toview:(UIView *)view2;
@end

and in the “.m” i have the following

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    // Override point for customization after application launch.
    [self.window makeKeyAndVisible];
    Disclaimerviewcontroller *aview = [[Disclaimerviewcontroller alloc]initWithNibName:@"Disclaimerviewcontroller"bundle:nil];
    self.firstview = aview;
    [_window addSubview:aview.view];
    [aview release];
    return YES;
}

-(void)switchview :(UIView *)view1 toview:(UIView *)view2{

    [UIView beginAnimations:@"Animation" context:nil];
    [UIView setAnimationDuration:0.50];
    [UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:self.window cache:YES];
    [view1 removeFromSuperview];
    [_window addSubview:view2];
    [UIView commitAnimations];


}

and the dealloc

- (void)dealloc
{   [firstview release];
    [_window release];
    [super dealloc];
}

from there on when ever I want to switch to another view I use the following code

-(IBAction)switchtodisclaimer2:(id)sender{

    GAINSAppDelegate *delegate = (GAINSAppDelegate *)[[UIApplication sharedApplication]delegate];
    Disclaimerviewcontrller2 *disclaimview2 = [[Disclaimerviewcontrller2 alloc]initWithNibName:@"Disclaimerviewcontrller2" bundle:nil];
    [delegate switchview:self.view toview:disclaimview2.view];


}

just like in the tutorial. but when I did an analyze test. xcode warned be of possible memory leak in the above code. so i added (in the above case) [disclaimerview2 release];and when I run the program I get EX_BAD_ACCES error. I thought since it was initwithnibname it was an autorelease ?. I’m confused now. the tutorial doesn’t seem to be addressing this at all.

  • 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-25T03:41:21+00:00Added an answer on May 25, 2026 at 3:41 am

    The rule for memory ownership is this :

    If your method name starts with ‘alloc’, ‘init’, ‘copy’, ‘mutableCopy’ or ‘new’ they you are responsible for releasing it, either with release or with autorelease

    So yes, you do have a memory leak so you should release ‘disclaimview2’ with [disclaimview2 release]

    However, the reason that you are crashing is because of another bug somewhere in your code.

    If you are going to pass it into your delegate, your delegate should retain it – otherwise, the delegate will try to use it at some point in the future but will have been deallocated.

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

Sidebar

Related Questions

I made a class. This is the h file. // MyClass.h #import <Foundation/Foundation.h> @interface
I made a multiview based application. My app has 3 views. The first is
Made a new project, added main.cpp and wrote the code at this URL: http://www.boost.org/doc/libs/1_43_0/doc/html/boost_asio/example/echo/async_tcp_echo_server.cpp
I made a lot of changes to my app : databases scheme, graphics, code,
Made a much simpler example, hopefully someone can follow this and help me Here
Made this nice little loop for hiding and showing div's, works as a charm
I made a class from Linq to SQL Clasees with VS 2008 SP1 Framework
I made a class that derives from Component: public class MyComponent: System.ComponentModel.Component { }
I made a code that translate strings to match each word from the array
I made a UIView using Interface Builder with a top bar that has Cancel

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.