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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T23:24:47+00:00 2026-05-30T23:24:47+00:00

Before I begin, I should probably mention that this sort of thing should probably

  • 0

Before I begin, I should probably mention that this sort of thing should probably have been implemented using the Core Data framework, but that is out of the question now.

We have data objects that are retrieved from a web service, and I’m trying to build a hierarchy for them, but I’m struggling.

I figured my base class should be called DataEntity, and defines an abstract property called EntityId and implements the hash method based on the entityId.

Any object retrieved from the web service can be implemented in one of two ways: By passing an NSDictionary to an entity, and letting it use that as its data source, or by passing the dictionary to an entity and letting it initialise its own data members from the dictionary. I have called these two types of entities DictionaryBackedDataEntity and ConcretedDataEntity. So my hierarchy would then be:

DataEntity -> DictionaryBackedDataEntity  
           -> ConcreteDataEntity

Then, consumers of this package/framework would only really care about the data members that are available to it, so I have created a protocol for each data type retrievable from the interface. So, for example, I could have a and an protocol, and these would have the data members that the DataEntity should expose.

So then, my hierarchy would look like this:

DataEntity -> DictionaryBackedDataEntity -> DictionaryBackedPerson <Person>
                                         -> DictionaryBackedAnimal <Animal>
           -> ConcreteDataEntity         -> ConcretePerson <Person>
                                         -> ConcreteAnimal <Animal>

Now, to be honest, I’m not sure whether I should be doing the above, or something like the below:

DataEntity -> PersonEntity      -> DictionaryBackedPerson
                                -> ConcretePerson
           -> AnimalEntity      -> DictionaryBackedAnimal
                                -> ConcreteAnimal

In the above, PersonEntity and AnimalEntity would be abstract classes, and so instances would either be DictionaryBacked or Concrete instances.

Does anyone have any experience or recommendations on how I should approach this? I seem to be going around in circles and can’t settle on a decision…

Regards,
N

  • 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-30T23:24:48+00:00Added an answer on May 30, 2026 at 11:24 pm

    Why not just have a single class DataEntity that stores it’s property values in a dictionary? I think you probably don’t need (and probably shouldn’t require) to differentiate between ConcreteDataEntity and DictionaryBackedDataEntity.

    @interface DataEntity
    @property ( nonatomic, retain ) NSMutableDictionary * properties ;
    @end
    
    @implementation DataEntity
    @synthesize properties ;
    
    @end
    
    @interface Animal : DataEntity
    @property (nonatomic) NSUInteger numberOfLegs ;
    
    -(id)initWithDictionary:(NSDictionary*)dict
    {
        if (( self = [ super init ]))
        {
            self.properties = dict ;
        }
    
        return self ;
    }
    @end
    
    @implementation Animal
    
    -(void)setNumberOfLegs:(NSNumber*)n
    {
        [ self.properties setValue:n forKey:@"numberOfLegs" ] ;
    }
    
    -(NSNumber*)numberOfLegs
    {
        return [ self.properties valueForKey:@"numberOfLegs" ] ;
    }
    
    @end
    

    As a start…
    You can save yourself some typing by using some of the more dynamic features of Obj-C here…
    Look here: https://github.com/davedelong/Demos/tree/master/DynamicStorage

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

Sidebar

Related Questions

Before I begin, I should tell you that this only happens in iOS 5.1.
before i begin, i should mention my actionscript skills are about a 5/10. that
I have class implementing Comparator<String> which should sort strings in such manner that strings
I apologize if this has been asked before, but I believe that for me,
Before I begin, I realize that the ECMA script specification will probably answer my
First of all, before I begin, I am using VC++ 2008 professional, running an
Before you answer this I have never developed anything popular enough to attain high
Before I begin, I would like to state that I KNOW the Apple Guidelines
In a function that reads data (data meaning exclusively strings) from disk, which should
Ok, I think before I start I should just say that I'm a complete

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.