@autoclosure
?Suggested approach: There are a few ways you could tackle this, but I would recommend either talking about the &&
operator or the assert()
function – something you use regularly, and so feel comfortable talking about in detail.
First, start with a simple definition: @autoclosure
silently turns a function’s parameter into a closure so that it can be executed on demand rather than immediately. Now, pick a specific example such as assert()
and explain why it’s used – the autoclosure behavior here ensures our assertion doesn’t happen in release mode, so it won’t have a performance impact when we ship apps to the App Store.
Estimated difficulty: Advanced
See the full list of iOS interview questions
Link copied to your pasteboard.