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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T04:33:21+00:00 2026-06-13T04:33:21+00:00

The necessity for protocols are to abstract the methods of classes which are not

  • 0

The necessity for protocols are to abstract the methods of classes which are not hierarchically related.

The similar things also can be done with the help a class (interface) which encompasses all those methods and subclass them ? (This is not really possible due to the Multiple inheritance problem since a class has to be derived already from NSObject.ignore the NSProxy case)

What special things that protocols can do than a class?

Are protocols trying to solve only the multiple inheritance problem?

  • 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-13T04:33:23+00:00Added an answer on June 13, 2026 at 4:33 am

    Protocols main advantage is, that they describe what a object should be able to do, without enforcing subclassing. In languages that dont have multiple inheritance such a mechanism is needed, if you want others programmers be able to use your classes. (see delegation)

    For an instance Java has something similar, called interfaces.

    This means a huge advantage, as it is very easy to build dynamic systems, as I can allow other developers to enhance my classes via a clearly defined protocol.

    A practical example:
    I am just designing a REST API and I am providing a Objective-C client library.
    As my api requires information about the user, I add a protocol

    @protocol VSAPIClientUser <NSObject>
    -(NSString *)lastName;
    -(NSString *)firstName;
    -(NSString *)uuid;
    @end
    

    Anywhere I need this user information, I will have an basic id-object, that must conform to this protocol

    -(void)addUserWithAttributes:(id<VSAPIClientUser>)user;
    

    You can read this line as: “I don’t care, what kind of object you provide here, as long as it knows about lastName, firstName and uuid“. So I have no idea, how the rest of that object looks like — and I don’t care.

    As the library author I can use this safely:

     NSDictionary *userAttributes = @{@"last_name" : [user lastName],
                                      @"first_name": [user firstName],
                                            @"uuid": [user uuid]};
    

    BTW: I wouldn’t call the absence of multi-inheritance a problem. It is just another design.

    “[…] If I revisited that decision today, I might even go so far as to remove single inheritance as well. Inheritance just isn’t all that important. Encapsulation is OOP’s lasting contribution.” — Brad Cox was asked, why Objective-C doesn’t have multiple inheritance. (Masterminds of Programming: Conversations with the Creators of Major Programming Languages, p. 259)

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

Sidebar

Related Questions

I would like to use Cassandra to store session related informations. I do not
I am having a protocol in which I have two methods as follows. @protocol
I don't understand the necessity for nested routes. There are many things about Rails
If necessity is the mother of invention, I'd like to kill the guy who
What is the necessity of using Application.DoEvents and when we should use it?
I have a necessity to sort a given HTML table of the following structure,
In Java I have the necessity of implementing a class that extends Thread within
I am reading SICP now and don't really understand the necessity of lexical addressing
Situation: Drupal 6 node module defining custom content type Necessity to have an automated
Am I right that using NHibernate (or any other ORM) removes the necessity of

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.