Xcode: Refactoring Tools Should Extract Into a Category

Originator:SlaunchaMan
Number:rdar://17255839 Date Originated:10-Jun-2014 03:49 PM
Status:Open Resolved:
Product:Developer Tools Product Version:Xcode 5.1.1 (5B1008)
Classification:Feature (New) Reproducible:Not Applicable
 
Summary:
When refactoring code, often I want to take something I wrote and promote it to a category in order to reuse it somewhere else. If I select a block of code with exactly one object declared outside of the selection, Xcode should offer to extract the selected code to a category on that object’s class.

Steps to Reproduce:
1. Write some code that performs a utility function on an object, such as this:

- (void)viewDidLoad
{
	[super viewDidLoad];
	
	self.view.layer.cornerRadius = 10.0f;
	self.view.backgroundColor = [UIColor clearColor];
	self.view.opaque = NO;
}

2. Select code. In this example, you would select the last three lines of the -viewDidLoad method.
3. Select Edit, then Refactor.

Expected Results:
There will be a way to create a category on UIView to perform the above actions.

Actual Results:
You can extract the three lines into a method, but it’s an instance method of the current class.

Regression:
N/A

Notes:
N/A

Comments


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!