<span id="Label3"><p><span style="line-height: 1.5;">1. Define Block</span></p><p><span style="line-height: 1.5;">Take the bool parameter as an example to return Nsinterger</span></p><p>1) as a parameter</p><p>Methodtakeblockasparamter: (nsinterger (^) (BOOL flag)) blockname</p><p><span style="line-height: 1.5;">2) as a variable or property</span></p><p>@property (copy, nonatomic) nsinterger (^blockname) (BOOL flag);</p><p>3) typedef</p><p>typedef nsinterger (^blockname) (BOOL flag);</p><p></p><p>2. Use note</p><p>1) If you set the block unexpected variable in the block, you need to add a __block identifier (two consecutive underscores) to the Variable.</p><p>2) if the object that owns (strong or retain) The block is referenced in the block, the retain cycle is created, and a variable pointing to the object is required and the __weak flag is used;</p><p></p><p>iOS Development Summary (A0)-Block</p></span>
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