Introduction, Shao

Source: Internet
Author: User

Introduction, Shao

I. Proxy design:

 

When object A has some behavior and wants to inform object B (let object B become the proxy object of object)

 

Object B wants to listen to some behaviors of object A (making object B the proxy object of object)

 

When object A cannot process certain behaviors, let object B be the proxy object of object)

 

2. Passing values between objects

 

Steps for using Proxy: first, identify who calls someone else's proxy and who acts as someone else's proxy

 

Please represent the trilogy:

 

1> write a protocol and list the tasks that you are not convenient (or do not want to) (@ protocol StudentDelegate <NSObject>)

2> include an object that complies with the protocol. The object can be of any type (id <StudentDelegate> delegate ;)

3> when you want to notify the proxy to do something, it is to call the corresponding method of the proxy.

([Self. delegate studentDidReceiveDelivery: self];)

 

When someone else's agent trilogy:

 

1> comply with the Protocol (@ interface Teacher: NSObject <StudentDelegate>)

2> implement the corresponding methods in the Protocol

3> set the proxy object and assign a value to the proxy object. Establish the proxy relationship between the two.

Related Article

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.