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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T19:38:37+00:00 2026-05-29T19:38:37+00:00

I’m newbie in Objective-C, and don’t understand why we need to use [super dealloc]

  • 0

I’m newbie in Objective-C, and don’t understand why we need to use [super dealloc], [super viewDidLoad] or [super viewWillAppear:animated]. When I create sample code application I see something like this:

- (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
}

- (void)viewDidAppear:(BOOL)animated
{
[super viewDidAppear:animated];
}

- (void)viewWillDisappear:(BOOL)animated
{
[super viewWillDisappear:animated];
}

 - (void)viewDidDisappear:(BOOL)animated
{
    [super viewDidDisappear:animated];
}

Actually Xcode 4 always add super method at the end for every automatic generated
method. Why?

Or when I use dealloc method. Why I need to add [super dealloc] at the end?

- (void)dealloc
{
 [nameField release];
 [numberField release];
 [sliderLabel release];
 [super dealloc];
}

P.S. Now I study “Beginning iPhone 4 Development”. And don’t find any reference about this method 🙁

  • 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-29T19:38:40+00:00Added an answer on May 29, 2026 at 7:38 pm

    The point is, that you are creating subclasses by inheriting them, in your case this seems to be a custom ViewController, e.g. MyViewController which inherits data and methods from UIViewController. Inheritance means, your class will have all the methods the parent class have, even if you don’t specify them. For example:

    @interface Foo : NSObject
    - (void) doSomething;
    @end
    
    @interface Bar : Foo
    @end
    

    Then the following is valid

    Bar *myBar = [[Bar alloc] init];
    [myBar doSomething];
    

    Even if you havent declared the method, it is found in the superclass and thus the superclasses method is called.

    Now suppose you have the following:

    @interface Bar : Foo
    -(void) doSomething;
    @end
    

    And the implementation for both is

    @implementation Foo
    - (void) doSomething
    {
      NSLog(@"This is a super important method that HAS TO BE CALLED IN ANY CASE");
    }
    @end
    
    @implementation Bar
    -(void) doSomething
    {
     NSLog(@"Well this is important, but not as important as Foos implementation");
    }
    @end
    

    Without a [super doSomething], the super important method will never be called since you have overridden it in your custom implementation. So when you do a

    Bar *myBar = [[Bar alloc] init];
    [myBar doSomething];
    

    the totally important code contained in Foo’s doSomething won’t be seen by the compiler as you provide the method in your class yourself, so only Bar’s version will be called.

    So whenever you override a method, you have to make sure that the base class version is called if it must be called, which is especially important for the dealloc method as this will release any memory the base class might have acquired during initialization.

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

Sidebar

Related Questions

I am trying to understand how to use SyndicationItem to display feed which is
link Im having trouble converting the html entites into html characters, (&# 8217;) i
Basically, what I'm trying to create is a page of div tags, each has
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I want use html5's new tag to play a wav file (currently only supported
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I need to clean up various Word 'smart' characters in user input, including but
I need a function that will clean a strings' special characters. I do NOT
I'm trying to use string.replace('’','') to replace the dreaded weird single-quote character: ’ (aka

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.