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

  • Home
  • SEARCH
  • 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 6124117
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T16:05:46+00:00 2026-05-23T16:05:46+00:00

As i was reading through the book on Objective-C , i came across an

  • 0

As i was reading through the book on Objective-C, i came across an example that initialized a class as follows:

ClassName *p = [[ClassName alloc] init]; 

While it makes sense that first we need to allocate memory to store data ClassName has before initializing, the following works just as well:

ClassName *p = [ClassName alloc]; 

Is init always needed?

  • 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-23T16:05:46+00:00Added an answer on May 23, 2026 at 4:05 pm

    In theory, it’s not technically required. That’s because NSObject‘s init method is effectively just return self;. However, in practice, it’s absolutely essential. Objects perform internal setup inside the init method – creating internal state, allocating private members, and generally getting ready for action. The init method may not even return the same object as you allocated.

    Think of it in two phases: alloc allocates memory, but that’s it – it’s analogous to Java’s new. init configures the state of the memory so that the object can perform it’s tasks – analogous to Java calling the constructor. Don’t leave it out!

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

Sidebar

Related Questions

Whilst reading through the book The well grounded Rubyist, I came across some strange
I was reading through a .NET 2.0 book and came across this sample code
Some while ago, I've been reading through the book SQL and Relational Theory by
I am reading through a book for homework, and I understand that using #'
I'm reading through Hartl's book, Ruby on Rails by Example. In chapter 11, it
I'm reading through head first design patterns at the moment and while the book
I'm reading through the dragon book and trying to solve an exercise that is
I am reading through a Learn C book right now and have come across
Reading through some of the questions here, the general concensus seems to be that
Reading through the SendAsync , BeginAsync method illustrations of Socket s, I realized that

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.