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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T03:29:52+00:00 2026-05-25T03:29:52+00:00

Common examples for a ObjC object are like this (for the header file): @interface

  • 0

Common examples for a ObjC object are like this (for the header file):

@interface A: B {
    int x;
    int y;
}
@end

Is it possible to avoid the inheritance specification (i.e. B here) in the header file?


In my case, the framework A defines that class A and another (sub-)framework B defines the class B (which is a subclass of NSView). A links to B. In my application, I link to A and I don’t need to know anything about B except that it is a subclass of NSView. And I want to avoid to link to B. But if B is in the header file, I think I cannot avoid it, that’s why I was asking about how to avoid it.

  • 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-25T03:29:52+00:00Added an answer on May 25, 2026 at 3:29 am

    no.

    you must often work around this with a class cluster, hold a private implementation, or create an object factory. then you can minimize the dependencies across modules.

    you’ll still ultimately need to link to the sub library at some stage if you intend to use it (e.g. create an instance of).

    Update – Demonstrate Private Implementations

    Private implementations can be entirely opaque. If you do expose them, here are two ways to implement private implementations which are visible to clients:

    via protocol:

    // MONDrawProtocol.h
    // zero linkage required
    // needs to be visible to adopt
    // may be forwarded
    @protocol MONDrawProtocol
    - (void)drawView:(NSView *)view inRect:(NSRect)rect;
    @end
    
    // MONView.h
    @protocol MONDrawProtocol;
    
    @interface MONView : NSView
    {
        NSObject<MONDrawProtocol>* drawer;
    }
    
    @end
    
    // MONView.m
    
    #include "MONDrawProtocol.h"
    
    @implementation MONView
    
    - (void)drawRect:(NSRect)rect
    {
        [self.drawer drawView:self inRect:rect];
    }
    
    @end
    

    via base:

    // MONDrawer.h
    // base needs to be visible to subclass and types which use MONDrawer
    // may be forwarded
    @interface MONDrawer : NSObject
    - (void)drawView:(NSView *)view inRect:(NSRect)rect;
    @end
    
    // MONView.h
    @class MONDrawer;
    @interface MONView : NSView
    {
        MONDrawer * drawer;
    }
    
    @end
    
    // MONView.m
    
    #include "MONDrawer.h"
    
    @implementation MONView
    
    - (void)drawRect:(NSRect)rect
    {
        [self.drawer drawView:self inRect:rect];
    }
    
    @end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This seems like a very simple and a very common problem. The simplest example
I've seen examples of this where an interface is provided to a factory and
What are some common , real world examples of using the Builder Pattern? What
In Peter Seibel's Practical Common Lisp , he gives this example: (do ((nums nil)
Common question but I could use an english explanation. Is it like Java where
This is probably a common Objective-C question reported by Java coders, but I don't
I recently ran into a piece of code very much like this one: var
I'm looking for good examples of multithreading practices in C#. I'd like to see
Possible Duplicate: Common Uses For Pointers? I am still learning the basics of C++
This probably isn't the most common filename parsing problem, but I have a program

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.