The Extract Typedef refactoring changes the selected declaration of a type to a
typedef definition. You can apply Extract Typedef when actual declaration is cumbersome, potentially confusing, or likely to vary from one implementation to another, or just to make code presentation more clear and readable.
Extract a typedef definition
In the editor, select the type declaration to be re-declared.
Press ⌃⌥K or selectfrom the main or context menu.
If there are several expressions available for extracting, select the required one from the list that opens and press ⏎.
If more than one occurrence of the selected expression is found, AppCode will suggest replacing all the occurrences or just the selected one. Select the desired option from the list that opens.
Select a name for the typedef from the list of suggestions that opens or type a new one.
Select Put to header if you want to move the typedef definition to the header file.
@interface LoginModel : NSObject - (void)loginWithEmail:(NSString *)email password:(NSString *)password // void (^)(BOOL success) will be extracted to a typedef completion:(void (^)(BOOL success))completion; @end
// Extracted typedef typedef void (^LoginModelCompletion)(BOOL); @interface LoginModel : NSObject - (void)loginWithEmail:(NSString *)email password:(NSString *)password completion:(LoginModelCompletion)completion; @end