Swiftpack.co -  TheAngryDarling/SwiftRawRepresentableHelpers as Swift Package
Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
TheAngryDarling/SwiftRawRepresentableHelpers
Provides helper methods for interchanging between a RawRepresentable and its RawValue
.package(url: "https://github.com/TheAngryDarling/SwiftRawRepresentableHelpers.git", from: "1.0.1")

Raw Representable Helpers

swift >= 4.0 macOS Linux Apache 2

This package provides helper methods where you may be using values in RawRepresentable Enums and have to call the .rawValue alot. When using Arrays or Dictionaries where you would have the Element or Key type the same as a Enum with a RawValue type the same, this package will provide simmilar getter/setter/add/remove methods so you don't need to add the .rawValue each time

Usage

enum CodingKeys: String {
    case key1
    case key2
    case key3
}

var dictionary[String: Any] = [:]
dictionary[CodingKeys.key1] = true
dictionary[CodingKeys.key2] = 1
dictionary[CodingKeys.key3] = "String"
dictionary.removeValue(forKey: CodingKeys.key2)

var array: [String] = []
array.append(CodingKeys.key1)
array.append(CodingKeys.key2)
array.append(CodingKeys.key3)
_ = array.contains(CodingKeys.key3)


Authors

License

This project is licensed under Apache License v2.0 - see the LICENSE.md file for details

Acknowledgments

GitHub

link
Stars: 0
Last commit: 1 year ago

Ad: Job Offers

iOS Software Engineer @ Perry Street Software
Perry Street Software is Jack’d and SCRUFF. We are two of the world’s largest gay, bi, trans and queer social dating apps on iOS and Android. Our brands reach more than 20 million members worldwide so members can connect, meet and express themselves on a platform that prioritizes privacy and security. We invest heavily into SwiftUI and using Swift Packages to modularize the codebase.

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API