Creating handmade mocks is a common task many of us have to suffer through in Swift. The last thing we want to do is write is more boiler plate code.
Xcode gives us some help; if we start typing the name of the method, Xcode can autocomplete it for us. But this can take ages for larger protocols. And who wants to jump back and forth between the protocol and the mock to remember the name of each method?
This AppCode moment is dedicated to the
Implement methods action.
|Menu item||Code → Implement methods...|
All your protocol methods are implemented in one fell swoop.
- It also adds a return statement when it can.
- If you already have implemented some of the protocol methods, it only adds the missing ones.
- It supports multiple protocols and inherited protocols.
- You can be selective about which methods to adopt; useful for delegates with optional protocol methods from Objective-C.
- Override methods (^⌘O) does the same but (you guessed it) suggests methods to override from superclasses.