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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T23:38:15+00:00 2026-05-27T23:38:15+00:00

I did find some suggestions for this topic but still there are some things

  • 0

I did find some suggestions for this topic but still there are some things left open for me.

The question is about designing an app (from a development point of view) especially concerning models.

For example, I’m building an app with the Facebook SDK. I guess it would make sense to have a model class for the communication with the Facebook API. And i guess it would make sense to make this class a singleton (doesn’t have to be).

But the Facebook SDK for iOS builds on delegates. So you send a request and the response returns in a delegate method in the model. That’s okay, but I also would like to assign a delegate to the model so that the view controller is then called.

So, for example, a view controller uses the Facebook-singleton-model to make a request but wants to set itself as a delegate for this request, so that the model calls this delegate when the request is finished.
But this model is a singleton it only has one delegate (and i want it to keep it like this).
So do i overwrite the delegate pointer in the Facebook-singleton before each call? (No good, because another request might start in the meantime using the same singleton and the delegate would be overwritten again).

So what is a good architecture? What are best practices for reusing models across an application?

  • 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-27T23:38:15+00:00Added an answer on May 27, 2026 at 11:38 pm

    I ended up using singletons for my models which works really well with the following thread-safe code of getting a sharedInstance (the singleton)

    +(QuizManager *)sharedInstance
    {
        static dispatch_once_t pred;
        static QuizManager *shared = nil;
    
        dispatch_once(&pred, ^{
            shared = [[QuizManager alloc] init];
        });
        return shared;
    }
    

    Working great is also the usage of Key-Value-Observing (KVO) in iOS. I can watch for changes on properties in the model and react in the view-controller. IMO this allows to create very clean and understandable code. (look it up and love it at: http://developer.apple.com/library/ios/#documentation/cocoa/conceptual/KeyValueObserving/KeyValueObserving.html)

    On one point I’m also using a Model and set it up as a delegate and gave it a set of delegates which than broadcasts the delegation methods to all observers, which i find is also kind of nice.

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

Sidebar

Related Questions

I found some threads saying this was doable, but did not find specific instructions
Did some googling and couldn't find a clear answer on this. My assumption is
I did some research but all I could find was syncing data core with
I did some research but couldn't find the answer I was looking for so
I did some research but cannot find a definite approval or disapproval. What I
I did not find an answer to this question. I have a VOIP application.
How to install Ldap on windows7 and to configure it?? Did some googling..cant find
I can't seem to find any info on this question, so I thought I'd
This might be a simple question, but am trying to access a button inside
I am interested in where string literals get allocated/stored. I did find one intriguing

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.