Does autoclosure respect weak'ness of a captured variable?

Yes. Whenever your event handler is called some time in the future, if self is no longer in memory, perform will be called with nil. You can easily verify it by calling perform using e.g. DispatchQueue.after to delay the call, and deallocate self immediately after.

2 Likes