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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T18:40:42+00:00 2026-06-18T18:40:42+00:00

I have reviewed many code samples and have found that people commonly declare all

  • 0

I have reviewed many code samples and have found that people commonly declare all methods and global variables in the header (.h) file. Is it necessary?

  • 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-18T18:40:43+00:00Added an answer on June 18, 2026 at 6:40 pm

    Methods to be used publicly (i.e. by classes other than the class implementing the method) and (truly) global variables should indeed be declared in the header file. The whole point is that you can import the header file in another source code file to gain access to the functionality declared there.

    Methods that are meant to be private — that is only to be called as part of the internal implementation of a class — can be declared in a class extension. With recent versions of LLVM/Xcode, you actually don’t even need to do that for non-@property methods. You can simply implement them and the compiler will be smart enough to see that they’re there when called from other methods in the same class’s implementation.

    If you need to explicitly define a private ivar (rare these days), you can do so in a brace-enclosed section immediately after @implementation or @interface ClassName ().

    In short: declare methods, functions, and variables that need be accessible from other classes in the .h file. Private methods and variable should be kept private by declaring them only in the .m file.

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

Sidebar

Related Questions

I have some code that saves a many to many relationship in code. It
I've reviewed many websites and youtube videos that have IOS 5 storyboarding information. Most
Thank you for submitting APPNAME_HERE. We have reviewed your application and have determined that
so I have been researching this all morning- and I'm pretty sure the code
I have a software that prints labels. It generates many pages with n columns
I have a colleague who insists that his code doesn't need comments, it's "self
I've reviewed many other posts on here and have become pretty familiar with the
This question has been asked before, but none that I have reviewed give a
As in the below code, textarea gets generated based on how many items criteriaList
I reviewed the many posts on this topic but can't seem to find the

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.