Skip to content

Provides helper methods for interchanging between a RawRepresentable and its RawValue

License

Notifications You must be signed in to change notification settings

TheAngryDarling/SwiftRawRepresentableHelpers

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

Provides helper methods for interchanging between a RawRepresentable and its RawValue

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages