To add a color, for example, the new Swift folder is not a cocoa class and does not need to inherit anything.
And then
1 Import UIKit2 3 Protocol colordalegate{4 classFunc Maincolor (Void)Uicolor5 }6 7 extension uicolor:colordalegate{8 classFunc Maincolor (Void)uicolor{9 returnUicolor.redcolor ()Ten } One}
This defines a colordalegate protocol, which is then implemented by Uicolor to implement the method declared in this protocol, and here's why it's written, and that's why you add that class,
If the Redcolo () of the system is called by Uicolor.redcolor () to see Redcolor's declaration to this interface, here is a partial intercept
1 classFunc blackcolor ()-Uicolor//0.0 White2 classFunc Darkgraycolor ()-Uicolor//0.333 White3 classFunc Lightgraycolor ()-Uicolor//0.667 White4 classFunc Whitecolor ()-Uicolor//1.0 White5 classFunc Graycolor ()-Uicolor//0.5 White6 classFunc Redcolor ()-Uicolor//1.0, 0.0, 0.0 RGB7 classFunc Greencolor ()-Uicolor//0.0, 1.0, 0.0 RGB8 classFunc Bluecolor ()-Uicolor//0.0, 0.0, 1.0 RGB9 classFunc Cyancolor ()-Uicolor//0.0, 1.0, 1.0 RGBTen classFunc Yellowcolor ()-Uicolor//1.0, 1.0, 0.0 RGB One classFunc Magentacolor ()-Uicolor//1.0, 0.0, 1.0 RGB
There is a class for each of them, although I do not know why, but like this kind of thing only need to imitate the system to write, it is absolutely correct.
Class extension extension in Swift