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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T05:18:07+00:00 2026-05-31T05:18:07+00:00

I have two categories defined for the same class and have same function but

  • 0

I have two categories defined for the same class and have same function but different definition. I want to choose a particular function of a category at runtime on some condition.
Does obj c compiler maintain some book keeping for categories.

I was thinking in terms of C++ (virtual function/Vtable) where these can be achieved using polymorphism. How can I solve such scenario in objective C.

Class MyClass;

File:Myclass+category1.h
@interface MyClass (CategoryOne)
-(void) printCategory()
@end 

File:Myclass+category2.h
@interface MyClass (CategoryTwo)
-(void) printCategory()
@end 

Now I included both the header files in MyClass.m. Is there any possibility of liberty of choosing the particular definition of “printCategory()” at some runtime condition?

  • 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-31T05:18:08+00:00Added an answer on May 31, 2026 at 5:18 am

    No. If two categories implement the same method, it is undefined which one is executed.

    From the docs:

    There’s no limit to the number of categories that you can add to a class, but each category name must be different, and each should declare and define a different set of methods.

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

Sidebar

Related Questions

I have two tables, movies and categories , and I want to get an
Say I have two tables I want to join. Categories: id name ---------- 1
In Django, I have two models: class Product(models.Model): name = models.CharField(max_length = 50) categories
Imagine you have two defined routes: map.resources articles map.resources categories, :has_many => :articles both
I have a many to many relationship (Sites, Categories, CategoriesXSite) and two iqueryable defined
I want clean URLs and have defined two routes: routes.MapRoute( Search, Search, new {
I have two categories, visible and hideMe... I want to list all posts in
I have two tables, omc_categories and omc_products. I want to pull out categories name
I have two tables of data categories and category relations. This is a setup
I have two objects. @Entity class Person extends Model { ... @OneToOne Category category;

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.