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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T20:47:10+00:00 2026-06-11T20:47:10+00:00

I use several categories for various classes in Objective-C and I am wondering is

  • 0

I use several categories for various classes in Objective-C and I am wondering is to be considered best practice for where you import those categories? For instance, here’s a nice category for NSDate. I have two options:

  1. I import this category only in the files I use it. I resist this only because I think that it will introduce clutter in my #imports. I like them to be succinct and meaningful.

  2. I import this category in the prefix header and simply use it haphazardly throughout the application. I resist this because it feels global variable-ish. But then again, categories are not state, they’re just behavior.

I’m curious to hear how a larger team handles this in their coding standards and the specific reasons for their chosen standard.

Thanks in advance!

  • 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-11T20:47:11+00:00Added an answer on June 11, 2026 at 8:47 pm

    Import it where it is needed.

    If it is needed in most of the files in your project, then putting it in the pch is not a terrible decision.

    However, consider what Apple does with their frameworks. They provide individual header files for each part so you can include the parts you want. But, they also provide a conglomerate header for the entire framework where you can include everything in the framework with one import.

    Now days, the compile times are so fast, that you don’t have to worry about being picky with includes as much as you used to (of course, you can debate whether this is a goo or bad thing).

    I have settled to import complete Objective-C frameworks. One-off libraries like the data category will get included in the files they are needed, unless they are obviously going to be needed in a large percentage of files.

    C++ files are still #included on a minimalistic as-needed basis.

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

Sidebar

Related Questions

I have several categories that I use in my Grails plugin. e.g., class Foo
I am using a QTreeWidget to display items in categories. Items will use several
I use several animations on my site. For example: moving some div's like here:
I use several custom tools during the build process, mostly code generators for service
I use several forms on my site to send data to MySQL. Which is
I have to use several SOAP messages to get data from a web service.
In my ViewModels I use several DataAnnotations to validate the form data, there are
I have a HTML form where I use several buttons. The problem is that
On the website I'm administrating, I use several include and require . I would
I'm developing a Mac OS X Cocoa app and want to use several .dylib

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.