/SwiftNillable

Protocol attached to Optional and NSNull which allows developers to check if an object is nil or not. This is good when working with type of Any like in Mirror, or Dictionaries where optional and NSNull types can be stored in Any

Primary LanguageSwiftApache License 2.0Apache-2.0

Nillable

swift >= 4.0 macOS Linux Apache 2

Protocol attached to Optional and NSNull which allows developers to check if an object is nil or not. This is good when working with type of Any like in Mirror, or Dictionaries where optional and NSNull types can be stored in Any

Usage

let properties: [String: Any] = [...]
for (k,v) in properties {
    if let vO = v as? Nillable, !vO.isRootNil  {
        //Get the root value, escaping all optionals
        let rValue = vO.unsafeRootUnwrap
    }
}

Authors

License

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