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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T03:46:55+00:00 2026-06-11T03:46:55+00:00

I often get confused with when to use DataSource Pattern and when to use

  • 0

I often get confused with when to use DataSource Pattern and when to use the Properties for providing configuration information to objects.

I have two ways to do this,

Generally I keep a lot of properties in the Object’s class that has to be configured and a method that resets the object and continues with the new properties.

And the for the Object which is configuring the other object, I keep a method that with the name configureXYZ:WithValues: , which resets the properties and calls the reset method of the object to be configured.

This I have seen with MPMoviePlayerController, that we have to set properties.

and Other way is how tableView works, all the configuration information comes from datasource methods.

Can anyone throw more light on which way is preferred in which scenario.

Because Its often I feel tempted to use design patterns and make the code look stylish but I wanted to know when do we actually need these.
I am absolutely clear with delegate pattern and have to use it on regular basis.
DataSource was one thing I was never clear with.

  • 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-11T03:46:57+00:00Added an answer on June 11, 2026 at 3:46 am

    When designing a class, the key factor you should consider when deciding between using a delegate or properties is how often the values can change. Properties work best if you will set the values one time and they should never change again. Delegates (of which datasource is just an example) work best if the values might change over time or change due to conditions.

    For example, in UITableView, the number of rows is highly dynamic. It could change for many reasons outside of the control of the table view. What the rows even represent is highly dynamic. They might be data; they might be menu options; they might be pieces in a game. UITableView doesn’t try to guess or control any of that. It moves it to a delegate (datasource) where potentially very complex decisions could be made.

    MPMoviePlayerController has a few controls that mean very specific things and should almost never change (particularly once the movie starts playing). Basically you set the thing up, hit play and walk away. In that case, a delegate would likely be overkill.

    There are many cases that are in the middle, and either way may be ok. I would encourage developers to consider delegation first, and then if it doesn’t make sense go with properties. This isn’t because delegation is always the right answer, but more because most C++- or Java-educated developers don’t think in terms of delegation, so should make a conscious effort to do so.

    Some other thoughts along these lines:

    • When using properties, it is ideal if they are configured at initialization time and are thereafter immutable. This solves a great number of problems.

    • If you find yourself needing a lot of properties, delegation is probably better and often simpler.

    • Delegate notification methods (somethingDidHappen:) are often better implemented as blocks. (Blocks are relatively new in ObjC. Many delegate-based Apple interfaces are moving to blocks, but you’ll see a real mix out there for historical reasons.)

    • The difference between “delegate” and “datasource” is that a delegate manages behavior, while a datasource provides data. They are typically implemented identically.

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

Sidebar

Related Questions

I often get this and have to press enter like 1-5 mins to get
I often get into situation when I'd like to use template method pattern, but
I use GridViews pretty often and sometimes I get confused to where to put
I am a beginner in Knockout and I must say I often get confused
I have some scripts that get run often, always from within a connected SQLPlus
I get this error in xml file very often. here is the code in
Often, when restarting Django runserver, if I use the same port number, I get
In requests to my application i often get ids of the objects, which should
I have noticed that with Delphi 2009, I often get strange errors when compiling,
I often get doubt on these two phases. The following is my understanding: Apply

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.