逃逸(escaping)/非逃逸(noescape)闭包清单

2017-11-24  本文已影响24人  tdt

本文是自己的加深理解和记忆的笔记,非原创。按照自己的理解习惯改写了其他文章的内容(引用资料在最下方),看看就好,最后强调一次,非原创。

[TOC]

1. 什么是逃逸闭包?如何标记?

A closure is said to escape a function when the closure is passed as an argument to the function, but is called after the function returns. When you declare a function that takes a closure as one of its parameters, you can write @escaping before the parameter’s type to indicate that the closure is allowed to escape.

即:作为一个传入参数,若该闭包在函数返回后才被执行的话,则该闭包就是在逃逸函数。(这样的闭包就是逃逸闭包。)你需要在参数前加上@escaping标记来表明闭包是逃逸的。

2. 什么情况下使用逃逸闭包标记?

3. 非逃逸闭包有什么限制

4.其他:

引用资料:

上一篇下一篇

猜你喜欢

热点阅读