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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T15:09:12+00:00 2026-06-05T15:09:12+00:00

The book I am reading says that after allocating an object I need to

  • 0

The book I am reading says that after allocating an object I need to call the init function on the instance. However, I did not see any differences in the functionality of the class when I don’t call the init method. So what exactly is the init function doing ? Below is the interface for the simple class:

@interface Fraction: NSObject
{
   int numerator;

   int denominator;
}
-(void) print;

-(void) setNumerator: (int) num;

-(void) setDenominator:(int) den ;

@end
  • 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-05T15:09:13+00:00Added an answer on June 5, 2026 at 3:09 pm

    init is meant to initialize all necessary instance variables so that the object is in a defined state. After alloc, all ivars are set to 0/nil/NULL, which might not be a permitted state for your object (for example, denominator should never be 0).

    The init method your class inherited from NSObject does nothing so if your class does not need to initialize any ivars you don’t have to implement your own. But it is good custom to always call init right after alloc, even if you know the method does nothing (who says this will remain true forever?).

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

Sidebar

Related Questions

I'm reading a book about parallel programming an it says that it's not thread
I am reading a book about Java and it says that you can declare
Reading a book (VS 2010), it says that commands (statements) in .NET Csharp cannot
Reading the book VS 2010 by John Sharp, it says that generics allows to
The book I am reading says that SQL Server supports two kinds of character
I'm reading the Cormen algorithms book (binary search tree chapter) and it says that
I'm reading about fork and exec for an exam, and my book says that
I am reading a book on data structures and it says that a left
I'm reading Petzold's free (.PDF) WP7 book, and he says that he always changes
So I was reading this book where it says that if I create a

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.