IOS Proxy and block inverse value learning

Source: Internet
Author: User
Tags notification center

In general, the reverse value of the project will need to use the proxy, block or notification center. Because the company's project bottom package is very good, so the project has been done for three or four months even if the need to reverse the situation is not to deal with their own. But recently encountered a special situation and need to deal with it yourself, before also on the Internet to see how to choose the agent, block or notification center. Personal feeling agent and notification center are relatively simple, block slightly more complex. Agent everyone will use, so at that time, the use of Notification center to deal with. After one time the company's network is too bad, there has been a failure of the reverse transmission of data, caused my attention, hit the breakpoint only to find that the method of notification center completely did not call, suddenly a want to remember, the company's controller is written, in the absence of the current controller, has been untied, Generally is the default in the destruction of the time to go to unbind, perhaps the company is the global processing in the absence of Jidushan when it was handled,

I would like to use the block of this seemingly upscale approach, but also more than the agent to write simple. Actually speaking of block is also simple, on three steps, define the Block property, call block, set block content.

Of course the agent we use is simpler, because too familiar, after a controller set up a protocol, set a delegate, in the previous controller jump to the back of a controller, the next controller to specify the agent for the previous controller, and then the previous controller to comply with the Protocol, and then implement the method in this Protocol , in this method there will be the data sent by the latter controller.

Let's get to the block order.

Define block, set block, call block

Define block and call block are in one place

Set block in another location

So where is the block defined and where is it called?

To pass out the data of the controller's H file to define this block property and with copy, as to why with copy, as if not copy, block in the stack area, after the destruction, with a copy after the block moved to the heap, the equivalent of the object, presumably this meaning.

The Block property is defined on the controller that is passing the data, and then the Block property has the controller (another controller) to set the block.

Why does the other controller have to set this block, in the controller definition block property to pass the data, the data will be passed to the block, and then the other controller will only set the block, To manipulate the data that is passed in the block as a parameter, such as setting it to its own control, property.

Pass the data side, define the Block property, determine if the Block property is true (there is a value, that is, the data receiver set to pass the data set on its own)

Data receiver, set this block, the parameters in the block (passed data) to the appropriate place (control display, sub-control distribution, property preservation re-processing)

IOS Proxy and block inverse value learning

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.