Convert
Last modified: 13 December 2022Convert refactorings allow converting methods to functions or blocks and vice versa, as well as converting properties to instance variables.
These refactorings are invoked from the Refactor menu. You can also use the Change Signature refactoring for the same purposes.
note
The Convert refactorings are available for Objective-C only.
Convert to method
The Convert to Method refactoring lets you convert a function or block into a method.
In the editor, place the caret at the function or block that you want to convert into a method.
From the main or context menu, select Refactor | Convert to Method.
In the dialog that opens, make changes if necessary:
To perform the refactoring, click Refactor. To see expected changes and make necessary adjustments prior to performing the refactoring, click Preview.
Before | After |
---|---|
|
|
Convert to function
The Convert to Function refactoring lets you convert a method or block to a function.
In the editor, place the caret at the method or block that you want to convert into a function.
From the main or context menu, select Refactor | Convert to Function.
In the dialog that opens, make changes if necessary:
To perform the refactoring, click Refactor. To see the expected changes and make the necessary adjustments prior to performing the refactoring, click Preview.
Before | After |
---|---|
|
|
Convert to block
The Convert to Block refactoring lets you convert a function or method into a block.
In the editor, place the caret at the method or function that you want to convert into a block.
From the main or context menu, select Refactor | Convert to Block.
In the dialog that opens, make changes if necessary:
To perform the refactoring, click Refactor. To see the expected changes and make the necessary adjustments prior to performing the refactoring, click Preview.
Before | After |
---|---|
|
|
Convert to property
The Convert to Property refactoring lets you convert an instance variable into a property.
Place the caret at the instance variable that you want to convert into a property.
From the main or context menu, select Refactor | Convert to Property.
In the dialog that opens, select instance variable(s) you want to convert:
Click OK to perform the refactoring.
Before | After |
---|---|
|
|
Convert to instance variable
The Convert to Instance Variable refactoring lets you convert a property to an instance variable.
Place the caret within the editor window.
From the main or context menu, select Refactor | Convert to Instance Variable.
In the dialog that opens, select the properties you want to convert:
Click OK to perform the refactoring.
Before | After |
---|---|
|
|
Thanks for your feedback!