iOS Programming Cookbook
上QQ阅读APP看书,第一时间看更新

Using extensions to extend classes functionality

For its name, extensions are used to extend an existing functionality. In Swift, you can extend classes, structures, protocols, and enumerations. Extensions are similar to categories in Objective-C except that extensions don't have names. It's very useful to add functionality to any type that you don't have access to its source code, such as native classes String, NSArray, and so on.