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

  • Home
  • SEARCH
  • 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 6836055
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T23:18:32+00:00 2026-05-26T23:18:32+00:00

I just don’t understand why some guys declare the methods in the .m file.

  • 0

I just don’t understand why some guys declare the methods in the .m file. Can’t those declarations just go in the .h file instead?? Here’s what I see mostly:

//myClass.h

#import <UIKit/UIKit.h>

@interface myClass: UIViewController
{

}

@end

And the implementation (.m) part:

//myClass.m

#import "myClass.h"

@interface myClass

//declare some methods here

@end

@implementation myClass

//the actual implementation

@end

Is there any difference when the methods are declared this way?? Also, “@private” methods can be declared in myClass.h itself, can’t they?

  • 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-26T23:18:33+00:00Added an answer on May 26, 2026 at 11:18 pm

    The code you have posted both doesn’t compile and isn’t equivalent to declaring methods in the header.

    The purpose of the header is to provide a set of declarations that other classes can import. They can’t import your implementation file, because that will create duplicate definitions.

    As bbum said, what you’re probably seeing is private method declarations in the implementation file. These aren’t intended to be used outside the class, so they’re declared in the implementation file. The feature is called a class extension:

    //MyClass.h
    
    #import <UIKit/UIKit.h>
    
    @interface MyClass: UIViewController
    
    // Declare methods that other classes should call here
    
    @end
    
    //MyClass.m
    
    #import "MyClass.h"
    
    @interface MyClass () // <--- NOTE THE PARENTHESES HERE
    
    // Declare methods that only this class should be using here
    
    @end
    
    @implementation MyClass
    
    // Define all your methods here
    
    @end
    

    And no, you can’t declare “@private methods” in the header, or anywhere else. There’s no such thing in Objective-C. The @private access specifier only applies to variables.

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

Sidebar

Related Questions

Sry but I just don't understand what is wrong in my syntext, can you
Well, I just don't seem to understand certain things about RegExp . Can someone
I just don't understand what's going on here and I've spent a lot of
I just don't understand how this is done. I've gone through several questions here
I just don't understand what's happening, I haven't change anything to the site for
Can anybody help with this code I just don't know where I am going
I've been searching all over the place and just don't see anyone doing it
Not that it matters strictly, and maybe I just don't yet fully understand how
I have just tried to save a simple *.rtf file with some websites and
just don't know how can I control over the visualization of links in my

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.