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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T05:40:48+00:00 2026-06-06T05:40:48+00:00

We always alloc before init in Objective C, then while writing init method, Why

  • 0

We always alloc before init in Objective C, then while writing init method, Why we don’t alloc a super and then initiate it?

- (id) init {
   if(self = [super init]){
      //init iVars
   }
   return self;
}
  • 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-06-06T05:40:50+00:00Added an answer on June 6, 2026 at 5:40 am

    When the child interface is allocated, its size includes the size of the parent. They aren’t separate objects, they’re combined. ‘super’ must be initialized so it can prepare its data members. Your object then initializes its members. For example, lets say you had a custom reference counting interface that needs to initialize ‘refCnt’ to 1. You then base your interface on that interface. That means your interface’s allocation size is the size of the reference counting interface + the size of your specific contributions. (e.g., ‘int refCnt’ in the reference counting interface and ‘int x’ in your interface means sizeof(your interface)==8~.) So, the allocation only needs to occur once. Then, you initialize ‘super’ (the reference counting interface, in this situation) so ‘refCnt’ will be 1. After that, you initialize your own data.

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

Sidebar

Related Questions

I always get responce NULL when call this method but in case if suppose
I always choose to 'Clean' my project before archiving it in my XCode projects,
I'm writing a little web-app and want to check the users connectivity before I
I just discovered the following: As I expected, releasing my object before I return
I always thought that by declaring var before the using will allow it to
My method + (void) initialized is not called and I'm very new in Objective
I'm trying to accept self-signed certificates in a NSURLConnection, as many have before me.
As always being this problem comes from a book's exercises. Neither I am not
I always thought that the nullable types of the .NET framework where nothing but
I always see this in the source code of my Browser Safari, although it

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.