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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T06:12:51+00:00 2026-05-23T06:12:51+00:00

It seems that I should implement three initializers. A main initializer is the one

  • 0

It seems that I should implement three initializers. A main initializer is the one that calls [super init] and all the variables are assigned in this method. But since other two initializers have non-overlapping arguments both of them calls the main initializer.

Is this approach correct ? In many examples a third level initializer call the second lavel and then the second level calls the first one while here both the first and the second level directly calls the first level initializer.

-(id)initWithAccount:(NSString *)account_name apiKey:(NSString *)api_key lineid:(NSString *)line_id runTitle:(NSString *)run_title data:(NSString *)stringData runID:(NSString *)run_id{
if(self = [super init]){
    accountName = [account_name retain];
    runID = [run_id retain];
    apiKey = [api_key retain];
    lineID = [line_id retain];
    data = [stringData retain];
    runTitle = [run_title retain];
}
return self;
}


-(id)initWithAccount:(NSString *)account_name apiKey:(NSString *)api_key runID:(NSString *)run_id{

return [self initWithAccount:account_name apiKey:api_key lineid:nil runTitle:nil data:nil runID:run_id];
}

-(id)initWithAccount:(NSString *)account_name apiKey:(NSString *)api_key lineID:(NSString *)line_id{

return [self initWithAccount:account_name apiKey:api_key lineid:line_id runTitle:nil data:nil runID:nil];
}
  • 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-23T06:12:52+00:00Added an answer on May 23, 2026 at 6:12 am

    To some extent it’s a matter of taste whether an initializer calls the designated initializer directly or through another initializer on the class. The important thing is, that the designated initializer gets called in any case.

    In your example you’re calling super with a comparison operator (==) instead of assigning it (=). You need to change this:

    if(self == [super init]){
    

    to either this:

    if((self = [super init])){
    

    or this:

    self = [super init];
    if(self != nil){
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

It seems to me that one should always properly dispose resources when calling Directory
It seems to be the general opinion that tables should not be used for
I have the following code that seems like it should set my insertParameter but
I have a Flex application that seems larger than it should be. There is
I am looking to write something that seems like it should be easy enough,
Has any one done this before? It would seem to me that there should
We are told that we should implement hashCode() for our classes but most people
I'm desperately looking for a Java HTML view engine that fulfills three main requirements:
Seems that requirements on safety do not seem to like systems that use AI
Seems that even after unchecking the option in the PyDev/Debug preferenecs pane to launch

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.