Skip to content

andrejs-mamontovs/MapToEnum

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MapToEnum

    // simple data representation
    public class Item {
        var Id: Int?
        var Name: String?
    }
    
    // field enumerator
    public enum Field : String {
        case Id, Name
    }

    // json as dictionary representation
    let arr:[String:Any] = ["Id": 1, "Name": "Record #1"]

    // link dictionary and enum
    let map = Map.link(arr, and: Field.self)

    // create data object
    let data = Item()
    
    // set value
    data.Id <- map[.Id]
    data.Name <- map[.Name]

About

Map key/value to object

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages