iOS common block/closure naming patterns

孙翔宇
1 min readJan 6, 2020

learn from the source code

If have problem of naming the closure/block for type-alias or variables. Check it out.

Providers

When the closure return an object, this naming is widely used. Especially in the iOS 13 APIs.

Creator also is used. But they represent similar meaning.

Handlers

When the return value of the closure is Void. It mean we are sending the target object as a parameter into the closure, the closure normally will process or read from the parameter. Most of the time it is perfect for inversion of control.

completionHandler

handler

Sometime Apple just being lazy.

changeBlock

--

--

孙翔宇

Swift + Bujinkan + Taiji. “A teacher’s role is transform an ambitious student to an aspiring one. “