小出しシリーズです。情報を小出ししていきます。
ExtensionsはObjective-Cでカテゴリと同じようにクラスを拡張で生きる機能です。Objective-Cのカテゴリはプロパティを追加できなかったのですが、Swiftは追加できるようです。ただし、追加できるプロパティはパブリックなもののみのようです。
“You can use extensions to add properties (including class and static properties). However, these properties must be computed; extensions can’t add stored properties to classes, structures, or enumerations.”
抜粋:: Apple Inc. “Using Swift with Cocoa and Objective-C”。 iBooks. https://itun.es/jp/1u3-0.l
Extensionsでプロトコルの指定もできるぽいです。
“You can also use extensions to add protocol conformance to a class without subclassing it.”
抜粋:: Apple Inc. “Using Swift with Cocoa and Objective-C”。 iBooks. https://itun.es/jp/1u3-0.l