Single-pass value of the value of an IOS page, block pass value

Source: Internet
Author: User

iOS page has a lot of values, the front has been sharing the value of the property and proxy value, today, mainly on the single-pass value and block value

Single-Case pass-through: a common pattern of development in a single case, because the object is the same object in the entire program whenever it is initialized, and the object has the same properties, so it can be used to pass values.

The block value is similar to the proxy value, which is mainly used for the second page to pass the value to the first page, and the block passes the specific steps:

On the second page:

1. Declaration: block typedef Void (^sendmessagerblock) (NSString *str);

2. Creation method:-(void) SendMessage: (sendmessagerblock) block;

3. Declaring properties: @property (nonatomic, copy) Sendmessagerblock block;

4. Implementation method:-(void) SendMessage: (Sendmessagerblock) block{
Self.block = Block;
}

5. Call Block:self.block (Self.textField.text);

On the first page

6. Calling method: [SECONVC sendmessage:^ (NSString *str) {
WeakSelf.textField.text = str;
}];

Single-pass value of the value of an IOS page, block pass value

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.