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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T05:44:26+00:00 2026-06-11T05:44:26+00:00

In an abstract class, a custom init method looks like this: – (id)init {

  • 0

In an abstract class, a custom init method looks like this:

- (id)init
{
    self = [super init];

    if (self)
    {
        //do some initialisations
    }

    return self;
}

This would work perfectly fine when working with abstract classes: no problems at all. However, when creating objects, I prefer Class *object = [Class new]; over Class *object = [[Class alloc]init];. The problem with such a method in my abstract class, is that this doesn’t work:

+ (id)new
{
    id object = [super new];

    if (object)
    {
        //do some initialisations
    }

    return object;
}

When trying to access properties of the object, Xcode will bring up an error, saying the corresponding property is not found on object of type ‘__strong id’. I’m guessing that’s because the compiler has no idea what properties my object has, as it’s just been created.

Is there any way to get around this limitation? If there’s not, I’ll just use the init method as it works just fine, but I was just curious about this.

  • 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-11T05:44:27+00:00Added an answer on June 11, 2026 at 5:44 am

    You don’t need to override new. According to the documentation, new…

    Allocates a new instance of the receiving class, sends it an init
    message, and returns the initialized object.

    So you only ever override init to perform your initialization. You’re then free to create instances via alloc/init or new, depending on your taste.

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

Sidebar

Related Questions

public abstract class MyAbs implements Comparable<MyAbs> This would work but then I would be
I have a custom type, which is abstract. and will have some class to
I'm currently looking at creating an abstract class Building . I would then like
I have this custom model, with some methods in it: class GenericModel < ActiveRecord::Base
abstract class base { abstract public function test(); public function run() { self::test(); }
public abstract class Master { public void printForAllMethodsInSubClass() { System.out.println (Printing before subclass method
If an abstract entity has it's own custom class, is that class usually abstract,
I have an abstract class A and several implementations of it. I expect this
I have an abstract class Exception in custom namespace which has no abstract methods.
In WPF I would like to create custom Inline implementation. From documentation of Inline

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.