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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T17:12:40+00:00 2026-05-16T17:12:40+00:00

The following is an example of how to create ‘private’ methods in Objective-C: MyClass.m

  • 0

The following is an example of how to create ‘private’ methods in Objective-C:

MyClass.m

#import "MyClass.h"
#import <stdio.h>

@implementation MyClass
-(void) publicMethod {
    printf( "public method\n" );
}
@end

// private methods
@interface MyClass (Private)
-(void) privateMethod;
@end

@implementation MyClass (Private)
-(void) privateMethod {
    printf( "private method\n" );
}
@end

Why does this example use the (Private) category name in the @interface MyClass (Private) and @implementation MyClass (Private) declarations? Aren’t interfaces declared in .m files automatically private? Do we need 2 different implementation blocks?

Is there a variation of this technique to create ‘protected’ methods?

(I’m new to objective-C. Am I missing the point of category names? Why do we need to use them in this instance?)

Thanks-

  • 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-16T17:12:40+00:00Added an answer on May 16, 2026 at 5:12 pm

    If you’re creating a category, you have to give it some name. The name Private for the category doesn’t have any special meaning to the language.

    Also, in modern Objective-C, this would be a better case for a class extension, which is declared like a nameless category (@interface MyClass ()) but the implementation goes in the main @implementation block. This is a relatively recent addition, though. The secret-category method in your example is the more traditional way of accomplishing roughly the same thing.

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

Sidebar

Related Questions

Given the following code example from MSDN: private void GetPixel_Example(PaintEventArgs e) { // Create
In the following example i can create an object dynamically via a string; however,
I am trying to create dynamic menus from the database using the following example
I am following this example (First comment), How to create a custom ListView with
I want to create URL re-write rules for following URL in htaccess. http://example.com/vedios/category/fun/ ->
I have the following example code: create table #tempmembers ( memberid int ) update
I have a common problem with ORACLE in following example code: create or replace
I have the following example code: create table Details( name varchar(20), age int, weight
I am trying to create the following example. <body> <resources> <string-array name=mytest> <item number=1>
I couldn't create SQL in mybatis using dynamic sort type as the following example

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.