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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T10:28:59+00:00 2026-06-02T10:28:59+00:00

I was going through one of Apple’s tutorial (your second iOS app). Basically, you

  • 0

I was going through one of Apple’s tutorial (your second iOS app). Basically, you have a primary data class and a data controller class. Controller class manipulates the primary data objects by creating an array that holds them.

Suddenly this pops up:

“…But the “create the master collection” task is a task that only the data controller object needs to know about. Because this method does not need to be exposed to other objects, you do not need to declare it in the header file.”

And turns out the initialization of the “master collection” appears in the .m file as a class extension instead of the header file. Why do we want to do this? What’s wrong with declaring the method of initialization within the header file directly?

Header file of the data controller:

#import <Foundation/Foundation.h>

@class BirdSighting;
@interface BirdsSightingDataController : NSObject

@property (nonatomic, copy) NSMutableArray *masterBirdSightingList;
- (NSUInteger)countOfList;
- (BirdSighting *)objectInListAtIndex:(NSUInteger)theIndex;
- (void)addBirdSightingWithName:(NSString *)inputBirdName location:(NSString *)inputLocation;

@end

this is the corresponding .m file:

#import "BirdsSightingDataController.h"
#import "BirdSighting.h"

@interface BirdsSightingDataController ()

- (void)initializeDefaultDataList; //class extension

@end

@implementation BirdsSightingDataController
...
  • 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-02T10:29:00+00:00Added an answer on June 2, 2026 at 10:29 am

    Putting methods in an interface inside of a .m file is the proper way of making methods hidden.

    –

    There’s nothing really “wrong” with declaring this method in the header file. You can do this if you want.

    However, it’s better practice to hide methods in your implementation file by using private header extensions if there’s no need to make the method public. This means that if no other class needs to call this method, or if no other programmer needs to call this method, then it’s better practice to keep the method private, or hidden.

    A case like this will help explain the situation:

    First, putting methods in a hidden interface extension in your .m files is a conscious decision. As another developer, if I am looking at your code and see that you have consciously decided to put a method in a hidden interface () in your implementation file, I will know that this method is used only in this class… and that YOU have done this on purpose.

    Furthermore, it is good practice because if you are developing an API which is going to be used by other people, or working on the same code base with other developers, it limits their ability to call specific methods outside of the class itself. That means, they can’t accidentally call the method from another object.

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

Sidebar

Related Questions

Going through the microsoft authentication tutorial listed here they have you create a master
I have been going through and re-creating Apple's Advanced Table View Cells example to
I am going through one of my .R files and by cleaning it up
I'm going through a big refactoring / speed tweaking of one of my larger
I'm going through a Fortran code, and one bit has me a little puzzled.
So far, I've tried simply going through my labels and adding each one to
Going through some documentation on modifying CGImageRef data, I came across a strange example
I am going through the Apple provisioning profile walkthrough documentation to create the binary
I was going through one of the tutorials where we add JTwitter.jar and work
I am going through some sample code from Apple. The following 5 statements are

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.