问题描述
我已经学习Swift一段时间了,并且已经阅读了Swift语言指南。
I have learnt Swift for a while and I have read the Swift language guide.
概念关闭对我来说是新的。我想我可以使用,但是在哪里可以使用?它有什么好处?
The concept closure is new to me. I think I can understand how to use it, but where I can use it? what is the benefit of it?
我用Google搜索并得到了答案
I googled and get the answer When to use closures in swift?
我认为答案并不令人满意。语言指南对此做了很多介绍,我想它是该语言的一个非常重要的功能,也许它已在框架中广泛使用。
I do not thinks the answer is satisfying. The language guide writes so much about it, I guess it is a very important feature of the language, and maybe it's widely used in the framework.
有人可以给我更多的例子来展示它的力量吗?
非常感谢。
Could anyone show me more example to show it's power?Thanks a lot.
推荐答案
问题可能有点广泛,但我将尝试重述。
The question might be a little broad, but I will try to recap.
引用
- animateWithDuration:animations:completion:
- urlSession(_:dataTask:didReceive:completionHandler:)
- sort(by:)
再次获得:这只是闭包的简单用法;您需要查看文档以获取更多详细信息。
AGAIN: it is just a simple usage of the closures; You need to check the documentation for more details.
我希望它能对您有所帮助。
I hope it helped.
这篇关于快速关闭有什么特殊用途吗?有什么好处?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!