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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T18:31:15+00:00 2026-05-13T18:31:15+00:00

Objective-C categories are extremely useful, but there are some problems with this power. These

  • 0

Objective-C categories are extremely useful, but there are some problems with this power. These come in basically two forms which I know of:

  • Two categories attempting to add the same convenience method. In this case, it is undefined which one is used. If you are careful – not adding too many methods or using particularly common method names – the first problem should almost never be an issue.
  • New methods being added to a class by a writer that clash with a category. In this case the category overrides the class method. Since the class may not be under my control, I am more worried about this problem.

Backporting changes should be fairly safe, but implementing interfaces or adding convenience methods seem more dangerous. I know that Cocoa seems to use it for convenience methods quite a lot, but then again the base class is under there control. I think maybe they are just using the categories to reduce dependencies – so a String class can have convenience methods for working in Cocoa, but if you don’t use Cocoa, it isn’t pulled in.

So, how safe are categories/what guidelines are there for keeping them safe?

  • 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-05-13T18:31:15+00:00Added an answer on May 13, 2026 at 6:31 pm

    Usually, when extending code not under your control (e.g. Foundation), it’s traditional to use a prefix or suffix on the method name to avoid these sorts of collisions.

    Example from Peter Hosey’s perform on main thread category:

    @interface NSObject (PRHPerformOnMainThread)
    - (id) performOnMainThread_PRH;
    @end
    

    It’s not the most beautiful solution, but if you’re worried about fragility it’s a good idea.

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

Sidebar

Related Questions

Is there a way to implement functionality like Class Categories (of Objective-C) or Extension
is it possible to do something like this in objective-c (using categories or something
Some programming languages have the feature of adding Categories to classes (for example Objective-C),
I have two categories defined for the same class and have same function but
Can some one explain to me the difference between categories and inheritance in Objective
I am little confused about some concepts around Objective-C protocols and categories. Can protocols
My objective is to [semi]automatically assign texts to different categories. There's a set of
Objective Change these filenames: F00001-0708-RG-biasliuyda F00001-0708-CS-akgdlaul F00001-0708-VF-hioulgigl to these filenames: F0001-0708-RG-biasliuyda F0001-0708-CS-akgdlaul F0001-0708-VF-hioulgigl Shell
I know of a couple of rules regarding Objective-C categories: Category methods should not
So, I understand that Categories in Objective-C can be used to add methods to

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.