1. @escaping
无法加在可选参数前面
只有在函数参数位置的闭包才是默认非逃逸的。包括可选(Optional)参数在内都是默认逃逸的。
Basically, @escaping is valid only on closures in function parameter position. The noescape-by-default rule only applies to these closures at function parameter position, otherwise they are escaping. Aggregates, such as enums with associated values (e.g. Optional), tuples, structs, etc., if they have closures, follow the default rules for closures that are not at function parameter position, i.e. they are escaping.
网友评论