Equator is useful extension for XCode IDE. This tool has a really simple mechanism, that allows to generate fully implemented Equatable
protocol extensions for swift objects just in two clicks.
- Download and extract
.zip
file containing latest release from the releases tab of the repo - Drag
Equator.app
to your Applications folder and run the app - Go to
System Preferences
->Extensions
->Xcode Source Editor
and enable the extension - Restart the Xcode
Select all lines of target class/struct/enum body.
struct User { <- Start of selection
public var name: String
public var id: Int
} <- End of selection
Go to Editor
-> Equator
-> Generate Swift Equatable
and you'll achieve:
extension User: Equatable {
static func == (lhs: User, rhs: User) -> Bool {
return lhs.name == rhs.name &&
lhs.id == rhs.id
}
}
Dmitry Frishbuter, dmitry.frishbuter@gmail.com
Equator is available under the MIT license. See the LICENSE file for more info.