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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T08:32:39+00:00 2026-06-13T08:32:39+00:00

I create one protocol method and I want to implement the protocol method in

  • 0

I create one protocol method and I want to implement the protocol method in multiple classes

@protocol XMLProtocol <NSObject>

- (BOOL) hasAllRequiredAttributes :(NSDictionary*)attributeMap;

@end

I have use this following class methods

#import "XMLProtocol.h"
@interface MachineA : NSObject<XMLProtocol>

and its implementation method I will implement the protocol method

- (BOOL) hasAllRequiredAttributes:(NSDictionary *)attributeMap {
  return false;
  }

and also i use this protocol method in another class

#import "XMLProtocol.h"
@interface MachineB : NSObject<XMLProtocol>

and its implementation method I will implement the protocol method

- (BOOL) hasAllRequiredAttributes:(NSDictionary *)attributeMap {
  return false;
 }

my thought is where should I call the protocol method. I totally confused. How can i do this.

  • 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-13T08:32:40+00:00Added an answer on June 13, 2026 at 8:32 am

    One way you can define a global implementation for your protocol method (if I understand correctly what you are asking) is defining a category on NSObject:

    @implementation NSObject (XMLProtocol)
    
    - (BOOL) hasAllRequiredAttributes:(NSDictionary *)attributeMap {
       return false;
    }
    

    By doing like this every object will have that method. Don’t know if this is sensible, but it’s a way.

    Another way would be defining a Machine base class from which both MachineA and MachineB derive; the protocol method would be defined in the base class:

    @interface Machine : NSObject <XMLProtocol>
       ...
    @implementation Machine
    - (BOOL) hasAllRequiredAttributes:(NSDictionary *)attributeMap {
       return false;
    }
        ....
    @end
    
    @interface MachineA : Machine
     ...
    

    and any derived class could redefine it, if required.

    This is not as “global” as the NSObject category, but it might be a better solution if you can define a base class for all the classes that need implement that protocol.

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

Sidebar

Related Questions

I want to create one new model class, which will be extended in all
I want to create one proc like below but it has error on syntax.
Basically I want to create one large object of many object in JavaScript. Something
I create one example in Android 3.0 and I use the fragment in it.
I create one table by using jquery : <div class=productlist style=float:left; id=productlist> <script type=text/javascript
I need to create one drop down list contains some Languages. By selecting any
I have to create one table using XSLT and CSS. The table should look
I would like to create one EMF object and use it in various Resource
I wanted to create one js file which includes every js files to attach
Say I create one object and add it to my ArrayList . If I

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.