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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T04:43:13+00:00 2026-05-31T04:43:13+00:00

Say we have parent class ParentViewController.h @interface ParentViewController …. @end ParentViewController.m @interface ParentViewController() –

  • 0

Say we have parent class

ParentViewController.h

@interface ParentViewController

....

@end

ParentViewController.m

@interface ParentViewController()

- (NSArray *)selectedItems;

@end

@implementation ParentViewController

.....

@end

And then we subclass it

ChildViewController.h

@interface ChildViewController : ParentViewController

....

@end

ChildClassViewController.m

@implementation ChildViewController

- (void)doSomething
{
    // XCode Warning Flag on this line
    NSUInteger count = [self selectedItems];

    .....
}

XCode will set Warning flag at the commented line and says that “Instance method ‘-selectedItems’ not found (return type defaults to ‘id’).

Yes I know that in ObjC there is no such thing as private methods, but using an empty category kind of gives the ability to do so. But somehow it does not get inherited by subclasses.

I usually fix it by moving the method from ParentViewController.m to ParentViewController.h. This feels weird, I loose the ability to make the method private just because I need to subclass it.

Now my question is:

  1. Why does the parent subclass cannot find those methods that is declared in its category at the .m file?

  2. Is there a way to remove the Warning Flag but without losing the ability to keep the method private.

Hopefully someone with more experience will be able to help explain this annoying issue.

  • 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-31T04:43:14+00:00Added an answer on May 31, 2026 at 4:43 am

    First, note that your “empty category” isn’t a Category at all, it’s a Class Extension. Class Extensions very similar to categories but they’re new in Objective C 2.0, and they differ slightly in their use. Primarily, the compiler will warn you if you don’t implement a method in a Class Extension, but it won’t with a Category. Anyways, on to the issue at hand…

    Privacy in Objective-C is all about visibility. If the compiler can’t see see the declaration of a method that’s being used, you’ll get a warning. Note that if you were to implement your subclass in the same file as your Class Extension, the compiler won’t warn you because it can see the declaration.

    Therefore, If you want to use “private” methods in subclasses, you just need some way of showing the compiler that those methods exist. My favorite pattern is to declare the private methods in a Category in a separate file (like MyClass_private.h). You then only import that interface into the implementation files of the base class and any derived classes that need to see it.

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

Sidebar

Related Questions

Say I have a parent interface/class like so interface Parent<T> {} And a number
Say I have the following code: class Parent { static string MyField = ParentField;
Lets say I have a parent class class parent { } ..... This parent
I have a parent class, let's say class main { ... } , and
Let's say I have something like this: abstract class Parent { protected function foobar($data)
say I have these models: class Parent(models.Model): slug = models.SlugField() class Child(models.Model): slug =
If I have an aggregate root which consists of say: class Parent { IEnumerable<Child>
Lets say I have a parent Class: Class Parent{ public: virtual void doSomething(){} }
Let's say I have an abstract parent class called shape, and that there are
Let's say I have a simple parent->child class structure as shown below Public Class

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.