官术网_书友最值得收藏!

Getting ready

In Swift, syntax is pretty easy, and that's why it is awesome. To extend any type, just type the following:

extension TypeToBeExtended{ 
} 

Inside the curly braces, you can add your extensions to the type to be extended. In extension, you can do the following:

  • Adding instance- or class-computed properties
  • Adding instance or class methods
  • Adding new initializers
  • Defining subscripts
  • Adding nested types
  • Conforming to protocols

Once you create an extension to any type, the new functionality will be available for all instances in the whole project.

主站蜘蛛池模板: 营山县| 开江县| 新田县| 靖州| 科尔| 会宁县| 通渭县| 井冈山市| 青海省| 焦作市| 敦化市| 淮安市| 酒泉市| 固阳县| 枣庄市| 秦皇岛市| 潢川县| 娄烦县| 桐柏县| 长宁县| 太谷县| 奉新县| 社旗县| 年辖:市辖区| 济南市| 尤溪县| 南昌市| 新密市| 饶平县| 邳州市| 夏河县| 红桥区| 武威市| 北宁市| 淮北市| 南开区| 兴海县| 英德市| 德庆县| 齐齐哈尔市| 华安县|