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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T09:15:07+00:00 2026-06-03T09:15:07+00:00

I have general question about designated initializer. I have a some class and from

  • 0

I have general question about designated initializer. I have a some class and from there i want to call a initializer, but before i started to fill my @properties with passing data i want to make data default. For example:

-(id)initWithDefault:(NSDictionary*)defaultTemplate
{
    self = [super init];

    _fontColor = [defaultTemplate objectForKey:@"color"];
    _fontSize = [[defaultTemplate objectForKey:@"size"] intValue];

    return self;
}

-(id)initWithTemplate:(NSDictionary*)template
{
    self = [self initWithDefault:myDefaultTemplate];

    //now i doing something with my template

    return self;

}

Is this is a way to prevent null @properties? It this a correct use of designated initializer? Of course you can assume that myDefaultTemplates is not null, and has not null object in keys.

  • 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-03T09:15:08+00:00Added an answer on June 3, 2026 at 9:15 am

    This seems fine with me. I would use the safe way (presented below), but otherwise your code is fine.

    -(id)initWithTemplate:(NSDictionary*)template 
    {
        if(self = [self initWithDefault:myDefaultTemplate]) {
    
            //now i doing something with my template
    
        }
    
        return self;
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Edit: There was some confusion, but I want to ask a general question about
I have some general question about algorithms, when You have some problem and You
I have a general question about Hibernate that I'm batteling with. I have class
I'm about to start using location services, but have a general question about how
I have a general question about how .dll/.libs are suppose to be used. I
I have a general question about the way that database indexing works, particularly in
i have a general question about how sql server evaluates the joins.The query is
i have a general question about properties and ivars. ive seen many different examples
I have a general question for the group. I am about to start a
I have a question about the Microsoft PPL library, and parallel programming in general.

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.