[Swift] How to simply describe dismiss that was not taught in the introductory book

I've learned how to write dismiss more simply, which wasn't taught in the introductory book, so I'll describe it here.

Dismiss in introductory books, etc. (when code completion is used as it is)

python


dismiss(animated: true, completion: nil)

Simpler dismiss

python


dismiss(animated: true)

Why can I omit completion?

・ From Apple official document dismiss1.png completion: (() -> void)? = nil) As described in, if you do not pass an argument to completion, nil will be passed without writing anything, so you can omit completion.

So what is completion?

・ From Apple official document image.png In other words

completion is It is a block for executing processing after the view controller is dismissed, and has no return value or parameter value. Maybe you put nil in this argument.

... apparently ... Lol

completion means completion </ b>, achievement </ b>, so A block of processing that is executed when a method is completed </ b> It seems good to remember.

By the way, when will it be executed?

・ From Apple official document image.png It seems that the processing inside the completion block is executed after viewDidDisappear is called.


It's become a little fun to read Apple's official documents, so I'd like to read it little by little as well as studying English.
Reference: Apple Official Document (dismiss)

Recommended Posts