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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T21:20:47+00:00 2026-05-25T21:20:47+00:00

I have a homework question which confused me, really badly. Below is a brief

  • 0

I have a homework question which confused me, really badly. Below is a brief explanation of a question.

Imagine you are developing an application that stores contact
information. The address book may contain many entity types e.g. Human
being, a company or anything else that has a contact information.

  • Now instead of explicitly checking every object type write a
    protocol that declares how an object must behave and successfully
    appear in your address book.

My understanding and efforts of answering this question is,

  1. Build a protocol which has common methods of each type of contact information under @required tag. And all other methods which are not similar in different contact(Such as fax number has association with company but not person…) under @optional. At runtime you can check whether an object responds to any given method by using selector.
    Doubt : However this is again explicitly checking object type indirectly, am I right?

  2. My second thought is to use something like abstract class in java. Which means inherited class’s from abstract class implements their own abstract methods. How ever as a naive iOS developer I don’t know how to implement this? and I am not sure whether this is going to solve my problem. I would like get enlighten if someone knows this.


External Reading done so far, Please let me know if the answer I am looking for is in one of these links. I will read it again to understand and solve this :). thanks.

  1. http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/ObjectiveC/Chapters/ocProtocols.html#//apple_ref/doc/uid/TP30001163-CH15-TPXREF144

  2. http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/ObjectiveC/Chapters/ocProtocols.html#//apple_ref/doc/uid/TP30001163-CH15-TPXREF146

  3. http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/ObjectiveC/Chapters/ocProtocols.html#//apple_ref/doc/uid/TP30001163-CH15-TPXREF149

  • 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-25T21:20:48+00:00Added an answer on May 25, 2026 at 9:20 pm

    A protocol is the same thing as a Java interface. It just defines which methods the class should support. Here’s a page that explains it clearly: http://www.otierney.net/objective-c.html#protocols

    Essentially if you want to make sure a class will have a phoneNumber method (accessor to the phoneNumber property) you would do something like this:

    @protocol ContactProtocol
    -(void) phoneNumber;
    @end
    
    @interface Person: NSObject <ContactProtocol> {
        ...
    }
    
    @interface Company: NSObject <ContactProtocol> {
        ...
    }
    

    And then at compile time (or live for xcode 4) it will tell you if you forgot to add the phoneNumber method to the Person or Company classes.

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

Sidebar

Related Questions

It might be for pedantic purposes but not homework. I have below question about
As question states, I am doing homework which have 2 variables BOOK, and MAGAZINE
I have in my homework some question about data structure: I have elements which
Okay, so I have another question on a prolog homework problem I am struggling
I have a homework and I need to evaluate which approach is better according
I'm a newbie with UML and Microsoft Visio. Today, I have a homework which
This is a homework question from compiler design course. I just need an explanation
Lets say that I have a header file a.hxx which includes b.hxx and c.hxx.
For a homework assignment I wrote some scala code in which I have the
I have this homework question: Assume a Database table has 0 records at time

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.