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

The Archive Base Latest Questions

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

I have an Offer class (NSManagedObject subclass) that I want to use to handle

  • 0

I have an Offer class (NSManagedObject subclass) that I want to use to handle offers made for purchases. One side of each offer is a buyer and the other side is the product. There is also a price. However these class instances that can be buyers have pretty different lineage and most likely will have different parent classes all the way back to NSManagedObject. Same thing is true for the products.

Because of this I don’t want to make “Buyer” and “Product” abstract classes that these items would inherit from. I’d much rather just have protocols “buyable” and “purchasable” and have classes implement how they are purchased and how they make purchases. Unfortunately it seems as though relationships in NSManagedObjects don’t allow you to specify classes by their protocols.

Any way around this? Can someone set me straight? Rob

  • 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-16T21:51:26+00:00Added an answer on May 16, 2026 at 9:51 pm

    You can’t assign a protocol because the context has to instantiate an actual object and protocols don’t tell the context what class to instantiate. E.g. if you tell the context to insert a Buyer protocol what subclass would actually get created?

    It sounds what you actually need are subentities. You would create abstract entities for Buyer and Product then relate both to Offer. Then for every variation of Buyer or Product create a subentity. The entities don’t have to add new properties they can just have a different name. This way, an Offer object will accept any subentity of Buyer in its buyer relationship and any subentity of Product in its product relationship.

    Then assign a different class to each subentity to customize the entities behavior.

    The key thing here for you is that the inheritance of the classes does not have to parallel in anyway the entity inheritance. Your class tree can be completely different than the entity tree. As long as the individual class maps onto the individual entity, it will work.

    Abstract entities are pretty much protocol definitions themselves. They define the interface an entity must have but do not themselves implement anything.

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

Sidebar

Related Questions

I have a class that offers up a few events. That class is declared
I have a class A that has a template parameter T. There are use
I have several service classes that have static methods and offer a service to
http://blog.helpcurenow.org/test/mockups/mar2010/lp.html In the above landing page, I have an offers box that has four
I have seen code where every class has an interface that it implements. Sometimes
I have a class library written in .Net that I would like to make
So I have a custom class Foo that has a number of members: @interface
I have a C++ class running in its own thread that needs to execute
I have a WinForms Application that I want to run at Mono at some
I have a generic class that I'm trying to implement implicit type casting for.

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.