Zhao_Xin
(Zhao Xin)
1
For example, I have an async query, I pass it an `@escaping resultHandler`.
If there is any results, the handler will run. However, if the result is
empty, the `@escaping resultHandler` will never run.
Is there any memory leak or something will happen if the `@escaping
resultHandler` never runs?
Zhao Xin
No, there is no requirement to invoke a closure at least once, escaping or not.
Slava
···
On Jul 11, 2017, at 3:55 PM, Zhao Xin via swift-users <swift-users@swift.org> wrote:
For example, I have an async query, I pass it an `@escaping resultHandler`. If there is any results, the handler will run. However, if the result is empty, the `@escaping resultHandler` will never run.
Is there any memory leak or something will happen if the `@escaping resultHandler` never runs?
Zhao Xin
_______________________________________________
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users
ddunbar
(Daniel Dunbar)
3
For example, I have an async query, I pass it an `@escaping resultHandler`. If there is any results, the handler will run. However, if the result is empty, the `@escaping resultHandler` will never run.
Is there any memory leak or something will happen if the `@escaping resultHandler` never runs?
No, assuming your handler has been written to not participate in a retain cycle (for example, ensuring you use [weak self] if appropriate).
- Daniel
···
On Jul 11, 2017, at 3:55 PM, Zhao Xin via swift-users <swift-users@swift.org <mailto:swift-users@swift.org>> wrote:
Zhao Xin
_______________________________________________
swift-users mailing list
swift-users@swift.org <mailto:swift-users@swift.org>
https://lists.swift.org/mailman/listinfo/swift-users
Zhao_Xin
(Zhao Xin)
4
Glad to know the answer. And thank you, Slava and Daniel.
Zhao Xin
···
On Wed, Jul 12, 2017 at 7:53 AM, Daniel Dunbar <daniel_dunbar@apple.com> wrote:
On Jul 11, 2017, at 3:55 PM, Zhao Xin via swift-users < > swift-users@swift.org> wrote:
For example, I have an async query, I pass it an `@escaping
resultHandler`. If there is any results, the handler will run. However, if
the result is empty, the `@escaping resultHandler` will never run.
Is there any memory leak or something will happen if the `@escaping
resultHandler` never runs?
No, assuming your handler has been written to not participate in a retain
cycle (for example, ensuring you use [weak self] if appropriate).
- Daniel
Zhao Xin
_______________________________________________
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users