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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T12:52:31+00:00 2026-06-18T12:52:31+00:00

Recently I have been wondering why people sometimes put methods in the .h and

  • 0

Recently I have been wondering why people sometimes put methods in the .h and interface areas of the code. I’m just asking because I know that it is not exactly necessary.

For example:

.h

@interface ViewController : UIViewController

- (IBAction) methodOne:(id)sender;
- (BOOL) doesChickenTasteGood;

and also:

.m

import "ViewController.h"

@interface ViewController ()
- (IBAction) methodOne:(id)sender;
- (BOOL) doesChickenTasteGood;

@end

@implementation ViewController

- (IBAction) methodOne:(id)sender {
      NSLog(@"Yay you poked me");
}

- (BOOL) doesChickenTasteGood {
      return YES;
}

@end

I’m just wondering if I should be putting some of my methods these areas.

EDIT: I am not asking why someone would redeclare these methods in both the .h and the interface part of the code. I am just asking why someone would put methods outside of the implementation of the .m file.

  • 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-06-18T12:52:33+00:00Added an answer on June 18, 2026 at 12:52 pm

    You would declare a method in the header if you want it to be visible to other classes. Methods declared only in the implementation file are invisible to other classes at compile-time, and so are effectively private (they can still be called due to Objective-C’s dynamic dispatch mechanism, but you’ll get a warning at the least.)

    Methods are placed in an @interface block in the implementation file as a way of declaring they exist prior to their use. This allows for more organized code (e.g. an @interface block that contains only graphics methods, or one that contains only math methods) while maintaining privacy from callers.

    If you have no methods in your header, then calling code will have no idea what to do with instances of your class.

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

Sidebar

Related Questions

Recently I have been trying to optimize my tables, mainly because I've learned alot
I recently have just been able to populate my core data DB. I have
Recently I have been interested in FTP servers and I was wondering how to
Recently I have been refactoring some of my C# code and I found a
I have recently been learning about doctypes, and was I wondering what the differences
This is something I have been doing recently and was wondering if others do
I have been writing C code for many years, but I recently came accross
I am quite new to web development, and recently, I have been wondering if
I have been using Asp.Net for designing web applications recently and was wondering if
Hey I have been programming for a few years now and just recently I

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.