全体として太一が感覚的に実践している事を論理的に説明しようと試みている為、
説明の粒度が適切でなかったり一貫性が無いように見える部分があるかもしれない。
普段やっているけども書ききれていない事も多分きっとある。
- コードを嗜む
- コードを学ぶ
- 武器を手に入れる
| import UIKit | |
| struct ImageCache { | |
| static func loadImage(url: URL, user: User) async throws -> (UIImage, User) { | |
| if let cachedImage = InMemoryImageCache.shared.get(forKey: url) { | |
| return (cachedImage, user) | |
| } | |
| let urlRequest = URLRequest(url: url) | |
| let (data, response) = try await URLSession.shared.data(for: urlRequest) |
| import csv | |
| import requests | |
| from bs4 import BeautifulSoup | |
| def parse_collection_item(item): | |
| h4 = item.find('h4') | |
| event = item.find('li', class_='video-tag event').text | |
| a = item.find('a', class_='video-image-link') | |
| link_path = a.get('href') | |
| url = 'https://developer.apple.com' + link_path |
| import SwiftUI | |
| struct ContentView: View { | |
| var body: some View { | |
| VStack { | |
| globeLabel | |
| .padding() | |
| } | |
| } |
| import SwiftUI | |
| struct ContentView: View { | |
| var body: some View { | |
| VStack { | |
| globeLabel | |
| .padding() | |
| .mainCell() // Applying quite simple custom modifier | |
| } | |
| } |
| import UIKit | |
| print(UITraitCollection.current.displayScale) // 3.0 (if device is iPhone 14.0) | |
| print(UIScreen.main.scale) // 3.0 (if device is iPhone 14.0) | |
| var pixelLengthForUIKit: CGFloat = { | |
| 1 / UITraitCollection.current.displayScale | |
| } |
| #!/bin/bash | |
| # ファイルパスを指定してください | |
| FILE_PATH="path/to/file.swift" | |
| # ファイルの内容を読み込みます | |
| content=$(cat "$FILE_PATH") | |
| # コメント行を削除します | |
| new_content=$(echo "$content" | sed -e '/^[[:space:]]*\/\/.*$/d') |
| import UIKit | |
| final class ContainerViewController: UIViewController { | |
| private let pageViewController: UIPageViewController = .init(transitionStyle: .scroll, navigationOrientation: .horizontal) | |
| private let childViews: [UIViewController] = { | |
| let vc0 = UIViewController() | |
| vc0.view.backgroundColor = .red | |
| let vc1 = UIViewController() | |
| vc1.view.backgroundColor = .red.withAlphaComponent(0.6) | |
| let vc2 = UIViewController() |
| import SwiftUI | |
| struct ContentView: View { | |
| var body: some View { | |
| MyTabView( | |
| tabContents: [ | |
| .init(id: 0, title: "foo", content: PageView(title: "foo", color: .yellow)), | |
| .init(id: 1, title: "bar", content: PageView(title: "bar", color: .red)), | |
| .init(id: 2, title: "baz", content: PageView(title: "baz", color: .brown)), |