This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import UIKit | |
| extension NSDataAsset { | |
| /// Load a data asset from a catalog and try decoding it to a specific Decodable type | |
| /// - Returns: An optional instance of type T decoded from the named data asset | |
| /// Usage: `NSDataAsset.decode(DocodableThing.self, asset: "my thing")` | |
| public static func decode<T>(_ type: T.Type, asset name: String) -> T? where T: Decodable { | |
| guard let asset = Self(name: name) else { return nil } | |
| return try? JSONDecoder().decode(T.self, from: asset.data) | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // DumpExample | |
| // This SwiftUI View explores use of the dump() function for manipulating the debugging display | |
| // of large, structured data. | |
| // | |
| // Created by Quinn McHenry on 2/17/22. | |
| import SwiftUI | |
| struct ContentView: View { |
OlderNewer