jsdw_ios/QuickLocation/Core/Extension/Optional+Extension.swift

22 lines
658 B
Swift
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

//
// Optional+Extension.swift
// DLSDK
//
// Created by osell on 2023/6/9.
//
import Foundation
/// nil
extension Optional {
public var safeInt: Int { safeNumber.intValue }
public var safeBool: Bool { safeNumber.boolValue }
public var safeFloat: Float { safeNumber.floatValue }
public var safeDouble: Double { safeNumber.doubleValue }
public var safeString: String { DL.safeString(self) }
public var safeNumber: NSNumber { DL.safeNumber(self) }
public var safeArray: [Any] { (self as? [Any]) ?? [] }
public var safeDictionary: [AnyHashable: Any] { (self as? [AnyHashable: Any]) ?? [:] }
}