It\'s possible to add extensions to existing Swift object types using extensions, as described in the language specification.
As a result, it\'s possible to create exten
Most examples I have seen mimic the Objective-C approach. The example extension above would be:
String+UTF8Data.swift
The advantages are that the naming convention makes it easy to understand that it is an extension, and which Class is being extended.
The problem with using Extensions.swift
or even StringExtensions.swift
is that it's not possible to infer the purpose of the file by its name without looking at its contents.
Using xxxable.swift
approach as used by Java works okay for protocols or extensions that only define methods. But again, the example above defines an attribute so that UTF8Dataable.swift
doesn't make much grammatical sense.