iOS Learning Delegate design mode

Source: Internet
Author: User

In review, these was the steps for setting up the delegate pattern between the objects, where object A is the delegate for Object B and Object B would send out the messages:

1. Define a delegate @protocol for object B.

2. Give object B A property for that delegate protocol.

3. Make object B send messages to it delegate when something interesting happens, such as the user pressing the Cancel or Done buttons, or when it needs a piece of information.

4. Make object A conform to the delegate protocol. It should put the name of the protocol in its @interface line and implement the methods from the protocol.

5. Tell object B, Object A is now the its delegate.

Tips

1.if screen A (object a) launches screens B (Object B) then you don ' t want screens B to know too much about the screens that in Voked it (A).

2.Using a delegate helps to abstract the dependency from screen B in screen A.

3.Anytime you want one part of your app to notify another part about something, usually in order to update the screens, you Want to use delegates.

4.if screen A opens screens B, then a can give B the data it needs. You simply make a property for the this data on the screen B and then the screen a puts something to this property right before it m Akes screen B visible. To pass the data back from the B to a would use a delegate.

iOS Learning Delegate design mode

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.