Foundation.Bundle

extension Foundation.Bundle
  • module From SwiftlyChordUtilities

    Returns the resource bundle associated with the current Swift module.

    Declaration

    Swift

    static let module: Bundle
  • Decode a JSON file from the bundle

    Declaration

    Swift

    func decode<T: Decodable>(
        _ type: T.Type,
        from file: String,
        dateDecodingStrategy: JSONDecoder.DateDecodingStrategy = .deferredToDate,
        keyDecodingStrategy: JSONDecoder.KeyDecodingStrategy = .useDefaultKeys
    ) -> T

    Parameters

    type

    The decodable type

    file

    The fil to decode

    dateDecodingStrategy

    The optional Date Decoding Strategy

    keyDecodingStrategy

    The optional Key Decoding Strategy

    Return Value

    The decoded file

  • json(from:) From SwiftlyChordUtilities

    Get the JSON data from a file in the bundle

    Declaration

    Swift

    func json(from file: String) -> String

    Parameters

    file

    The JSON file

    Return Value

    The content of the JSON file