What is the difference between datasource and delegate?

Source: Internet
Author: User

Lukeluke

Is it datasource? It provides data that is not in the original object. For example, there are several items in total,

In delegate, the original data is provided, but the object itself does not know which data to use now?

 

Zzxap

Delegate is a proxy.

Datasource is a data source.

Wind, ox, and horse

 

Forbertl

The items in the datasource protocol are related to content, mainly cell constructor and various attributes.

The methods in the delegate protocol are mainly related to operations, such as mobile editing. You should write down the methods you want to use.

 

Cxyi99o6i

First, delegate means delegation. In oC, It is a class that delegates another class to implement a certain method. When an object receives an event or notification, it queries its delegate object to see if it can respond to the event or notification, if you can, this object will send a message to its delegate object (execute a method call ).

 

Datasource is a data source. Generally, it is associated with delegate. The data processed by the data source is the data in the delegate class sent in delegate and sent to the delegate class through datasource.

 

Instead of being delegated control of the user interface, a data source is delegated control of data. this sentence on the official website provides a better explanation. We can find that delegate controls the UI, the upper layer, and datasource controls the data. They are essentially callback, but the callback objects are different. (Official Website: https://developer.apple.com/library/ios/#documentation/General/Conceptual/DevPedia-CocoaCore/Delegation.html)

 

 

Others:

1. The main value of delegation is that it allows you to easily mimize the behavior of several objects in one central object.

The main value of delegation is that you can customize the features of multiple objects in a core object.

2. Helper Object (delegate and datasource) are commonly used to add functionality to an existing class without having to subclass it.

Build Helper Object. helper object is used to add features to existing classes instead of implementing them through subclass inheritance.

I would like to thank arachide for its comment. Original: http://www.cocoachina.com/bbs/simple? T6289.html

 

Lukeluke

Thank you!

 

Biaobiaoqia 2012-05-22 23:12

 

Like the third floor, relatively thorough ~

The first floor of the children's shoes does not seem to have this idea of research... In fact, they are all callback implementations, all belong to the adapter mode, not irrelevant.

 

Lukeluke

Alas, I actually know that callback is a kind of callback, but I just feel that the callback is divided into two concepts... I also know the corresponding MVC mode .. In the beginning, all data is provided. In fact, there is no difference...

 

Later I thought, maybe the data given by the datasource interface is not in the array. We need to calculate the data, such as several items.

But the delegate interface, the data to be given, is actually available in the ui or model, but we need to manually pick them out and tell the program ..

 

This corresponds to the Controller corresponding to the delegate in MVC, mainly in the data retrieval process.

 

The model corresponds to datasource, mainly to provide data

 

This concept.

 

From: http://www.cocoachina.com/bbs/simple? T103898.html

 

What is the difference between datasource and delegate?

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.