chevron-up bell reply instagram twitter2 feed3 finder search-25px-p0

Swift Extension and Objective-C category


Category in Objective-C, Extension in Swift are the same concept. They can help you to organise your class code. With category and extension, you don't have to create a inherited class.

Extension in Swift

Step 1: Create a Swift file

Then in the Swift file:

Step 2: Use extension:

Compared with the Category in Objective-C

Step 1: Create a Objective-C file

Select Category in the file type, and choose the class you want to extend:

Then it will create two files:



To use the category in your project, i.e. Change the background color of current view controller.


Make Your Comments