Inline
Last modified: 18 January 2023Language: Objective-C, Swift
Shortcut: Ctrl+Alt+N
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 Refactor | Inline 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.
SwiftObjective-CBefore
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"; }
Thanks for your feedback!
Was this page helpful?