Block for IOS development and iosblock

Source: Internet
Author: User

Block for IOS development and iosblock
Block for IOS development 1. What is block? The role of block

Common UI development and network functions implement callback. The button event processing method is the callback method.

(1) The target action button is passed in by a method.

(2) input the pointer self in the table view and call back the method in the View Controller.

(3) block statement block, which solves the callback. It is understood as an "anonymous function" and is defined in the method.

2. Basic use (syntax) of block to define block Variables

Void (^ block )();

Define block statement Blocks

Block = ^ void (){

NSLog (@ "I am block ");

};

// Execute

Block ();

Block parameters and return values

Int (^ myAdd) (int x, int y) = ^ int (int x, int y)

{

Return x + y;

};

Int s = myAdd (3, 5 );

NSLog (@ "s = % d", s );

    

3. block application in Development (OC, UI, Network)

BlockUseDemo

Http:// I .cnblogs.com/Files.aspx

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.