Skip to content

byvf/IntValue

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 

Repository files navigation

IntValue

Property Wrapper

Overview

IntValue is a simple @propertyWrapper for object.

  • It can be implemented in object.
  • Look examples in code.

Simple Example

Code Implementation

First: Need to create struct uses @IntValue

struct Object: Decodable {
    @IntValue var id: Int
    @IntValue var value1: Int
    @IntValue var value2: Int
}

JSON For Decode data

let json = """
    {
        "id": null,
        "value1": 0,
        "value2": 343
    }
    """
let data = json.data(using: .utf8)!
let object = try! JSONDecoder().decode(Object.self, from: data)

print("Id is", object.id)
print("Value1 is", object.value1)
print("Value2 is", object.value2)

Result in console:

Id is 0
Value1 is 0
Value2 is 343

Contributed

This is an open source project, so feel free to contribute.

About

Property Wrapper

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages