AppCode
 
Get AppCode
You are viewing the documentation for an earlier version of AppCode.

Extract function

Last modified: 21 July 2022

Language: Swift, Objective-C

Shortcut: ⌃ ⌥ M

The Extract Function refactoring lets you take a code fragment that can be grouped together, move it into a separated function and replace the old code with the function call.

The Extract Function refactoring has the following limitations:

  • Refactoring does not work with multiple output values in the automatic mode. You have to change your code before applying the refactoring, for example, you may introduce a special data-class that contains all output values.

  • Refactoring does not work for a code fragment which conditionally returns from the containing method and is not placed at the end of it.

https://resources.jetbrains.com/help/img/idea/2022.2/ac_extract_method.png
Gif

To reverse the Extract Function refactoring, press ⌃ ⌥ N to invoke the Inline refactoring.