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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T10:07:23+00:00 2026-05-29T10:07:23+00:00

I have a super class ‘Node’ and several sub classes e.g. ‘SubNode1’, ‘SubNode2’ etc.

  • 0

I have a super class ‘Node’ and several sub classes e.g. ‘SubNode1’, ‘SubNode2’ etc.

I need to have a property which all the sub classes need called ‘parentNode’. It gets set when init is called on ‘SubNode1’ and the object is passed through of type ‘Node’. The reason I used a sub class is because these objects are comforming to a protocol and I cannot use the sub class each time – I need to pass ‘Node’ around.

What I don’t know is how to structure my objects. Where should the release be and where should the property be and should it be retain as I constantly get exe_bad_access errors because of this.

This is how I have structured it currently:

Node.h

 @property (nonatomic, retain) Node *parentNode;

Node.m

- (void)dealloc {
    [parentNode release];
    [super dealloc];
}

SubNode1.h

@interface SubNode1 : Node
{
    // No reference to parentNode property
}

SubNode1.m

- (id)initWithParentNode:(SubNode1 *)theParentNode {
    self = [super init];
    if (self) 
    {
        super.parentNode = theParentNode;
    }

    return self;
}

- (void)dealloc {
    [super dealloc];
}
  • 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-29T10:07:25+00:00Added an answer on May 29, 2026 at 10:07 am

    You’re already designing it the correct way. The error is probably that:

    super.parentNode = theParentNode;
    

    should be:

    self.parentNode = theParentNode;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a super-class named ClassA and two sub-classes Class1 and Class2. I have
I have this set of classes: Node (SUPER Class) |------ NodeType1 (Class) |----------NodeType2 (Class)
Say you have a sub class B which inherits from super class A. You
I have done a few projects lately using a Database Object super class which
I have a abstract super class called RealAlgebraicNumber and two inherited classes called IntervalRepresentation
I have an abstract class called camera which PointCamera uses as its super class.
I have a super class Vehicle and three classes that extend on it: Bus
I have this class which I need to inherit. class AuthenticationForm(forms.Form): username = forms.CharField(label=_(Username),
I have this super class which extends from another class public abstract class AbstractDOEMessageFinderAction
I have a class Super and several subclases Sub1, Sub2,... Is there a way

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.