AppCode 2023.1 ヘルプ

インライン化

インライン化リファクタリングでは、メソッド、変数 (Objective-C の場合)、およびクロージャ (Swift の場合) の抽出リファクタリングを反転させることができます。

  1. インライン化するコードフラグメントにキャレットを配置します。

  2. Ctrl+Alt+N を押すか、コンテキストメニューまたはメインメニューからリファクタリング | インライン化を選択します。

  3. Swift 用: 開いたダイアログで、リファクタリングの実行方法を選択します。

    Inline method in Swift
  4. リファクタリングの結果をプレビューするには、Objective-C の場合は使用箇所の表示、Swift の場合はプレビューをクリックします。

    Show usages in Objective-C
  5. 以下はメソッドをインライン化した結果です。

    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" }

    - (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"; }