Inline
The Inline refactoring lets you reverse the Extract refactoring for a method , variable (for Objective-C), and closure (for Swift).
Place the caret at the code fragment you want to inline.
Press Ctrl+Alt+N or select
from the context or main menu.For Swift: in the dialog that opes, select how the refactoring should be performed:
If you want to preview the refactoring results, click Show usages for Objective-C or Preview for Swift:
Below is the result of inlining a method.
Before
After
private func setupUI() { // // This method will be inlined setupLabel() } private func setupLabel() { self.labelInfo.textColor = UIColor.black self.labelInfo.text = "Enter your email and password" }private func setupUI() { // Inlined code self.labelInfo.textColor = UIColor.black self.labelInfo.text = "Enter your email and password" }Before
After
- (void)setupUI { // ... // This method will be inlined [self setupLabel]; } - (void)setupLabel { self.labelInfo.textColor = [UIColor blackColor]; self.labelInfo.text = @"Your email and password"; }- (void)setupUI { // ... // Inlined code self.labelInfo.textColor = [UIColor blackColor]; self.labelInfo.text = @"Your email and password"; }
Last modified: 18 January 2023