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
| extension Array where Element: Collection, Element.Index == Int { | |
| func showTable() { | |
| transposed() | |
| .map { $0.map { "\($0)" } } | |
| .map { | |
| let max = $0.map { $0.countAsHalfWidth }.max()! | |
| return $0.map { $0.padding(length: max) } | |
| } | |
| .transposed() | |
| .map { "| " + $0.joined(separator: " | ") + " |" } |
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 Foundation | |
| @Observable final class Pong { | |
| var squares: [Square] = [] | |
| var balls: [Ball] = [] | |
| var dayCount = 0 | |
| var nightCount = 0 | |
| var generation = 0 | |
| private var cols = 0 |
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
| extension Collection where Element: Collection, | |
| Self.Index == Int, Element.Index == Int { | |
| func transposed1() -> [[Element.Element]] { | |
| let cols = 0 ..< (self.first?.count ?? 0) | |
| let rows = 0 ..< self.count | |
| var result: [[Element.Element]] = [] | |
| for col in cols { | |
| var newRow: [Element.Element] = [] | |
| for row in rows { |
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
| 2025-03-03 | |
| +------+------------+-------+-------+----------+----------+ | |
| | iOS | RELEASE | WW % | JP % | WW SUM % | JP SUM % | | |
| +======+============+=======+=======+==========+==========+ | |
| | 16.0 | 2022-09-12 | 0.59 | 0.61 | 91.15 | 93.86 | | |
| +------+------------+-------+-------+----------+----------+ | |
| | 16.1 | 2022-10-24 | 1.23 | 1.43 | 90.56 | 93.25 | | |
| +------+------------+-------+-------+----------+----------+ | |
| | 16.2 | 2022-12-13 | 0.62 | 0.79 | 89.33 | 91.82 | | |
| +------+------------+-------+-------+----------+----------+ |
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 SwiftUI | |
| import SwiftData | |
| struct BackyardBirdsDataContainerViewModifier: ViewModifier { | |
| let container: ModelContainer | |
| init(inMemory: Bool) { | |
| container = try! ModelContainer(for: DataGeneration.schema, configurations: [ModelConfiguration(isStoredInMemoryOnly: inMemory)]) | |
| } | |
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 SwiftUI | |
| import SwiftData | |
| public extension View { | |
| func backyardBirdsDataContainer(inMemory: Bool = true) -> some View { | |
| modifier(DataContainerViewModifier(inMemory: inMemory)) | |
| } | |
| } | |
| struct DataContainerViewModifier: ViewModifier { |
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 SwiftUI | |
| // 1 | |
| //struct Parent: View { | |
| // @State private var isOn = false | |
| // | |
| // var body: some View { | |
| // VStack { | |
| // Rectangle().fill(isOn ? .yellow : .gray) | |
| // Toggle(isOn ? "ON" : "OFF", isOn: $isOn) |
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
| struct ItemRow: View { | |
| var body: some View { | |
| VStack(alignment: .leading) { | |
| Text("ベイスターズ優勝") | |
| .font(.headline) | |
| .background(.white) // * | |
| Text("2023-12-28") | |
| .font(.caption) | |
| .foregroundStyle(.secondary) | |
| .background(.red) // * |
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 SwiftUI | |
| import PlaygroundSupport | |
| struct ParentView: View { | |
| @State private var text: String = "" | |
| var body: some View { | |
| VStack { | |
| TextField("Parent", text: $text) | |
| Text(text) |
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
| struct BirdsSearchResults<Content: View>: View { | |
| private var searchText: Binding<String> | |
| private var content: (Bird) -> Content | |
| @Query(sort: \Bird.creationDate) private var birds: [Bird] | |
| init(searchText: Binding<String>, @ViewBuilder content: @escaping (Bird) -> Content) { | |
| self.searchText = searchText | |
| self.content = content | |
| } |