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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T17:28:47+00:00 2026-06-15T17:28:47+00:00

In Objective-C, if I have a class that contains only class methods (no member

  • 0

In Objective-C, if I have a class that contains only class methods (no member variables or instance methods) can I define class methods in the class’s header file (.h), and skip creating a .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-15T17:28:48+00:00Added an answer on June 15, 2026 at 5:28 pm

    You can, but you basically shouldn’t. While you can put your @implementation in a header, it’s counter-convention and it may have unintended side-effects, the same as in C++ or other languages (e.g. you can’t control what will have been #included before your header was #include, so you can’t be sure you have a sane global namespace).

    The best practices in Objective-C are to keep only declarations in header files, along with documentation. Since the documentation is generally quite verbose (if written well) that’s already a fair bit of content in your header – adding code on top of that would be too much.

    Keep in mind also that there’s no inlining of Objective-C methods, whether class or instance. That’s one of the big reasons putting code in header files is a relatively popular practice in C/C++. You can of course put static functions in your Objective-C header file, so you could implement your code that way, but that may be an undesirable design – for example, class methods provide a form of namespacing which is generally wise to take advantage of.

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

Sidebar

Related Questions

In Objective-C (probably in C too) I can have a header file which can
I have some Objective-C code that looks like this: #define myVar 10 float f
I have a class that contains multiple user objects and as such has an
I have a class that contains an NSDictionary and periodically, I have a thread
I have an Objective-C++ class that adds itself as an observer for an event
I wrote a BinaryReader class in Objective-C that can extract an NSString from bytes
I have a C++ library (.h only) that contains the implementation of a data
I'm trying to make a Parcelable class that contains byte array. I have been
So, I understand that Categories in Objective-C can be used to add methods to
I'm new in objective-C and i wonder if its correct: I have a class

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.