blog
blog copied to clipboard
🍁 What you don't know is what you haven't learned
Need to use `Coordinator` conforming to `UITextViewDelegate` to apply changes back to `Binding` ```swift import SwiftUI import UIKit struct MyTextView: UIViewRepresentable { @Binding var text: String final class Coordinator: NSObject,...
Every new architecture that comes out, either [iOS](https://github.com/onmyway133/fantastic-ios-architecture) or [Android](https://github.com/onmyway133/fantastic-android-architecture), makes me very excited. I'm always looking for ways to structure apps in a better way. But after some times,...
Use `Solana.swift` and `Mnemonic` seed phrase. For production, change endpoint to mainnet ```swift import UIKit import Solana import KeychainAccess enum SolanaError: Swift.Error { case accountFailed case unauthorized } final class...
Specify `minWidth` to ensure miminum width, and use `.layoutPriority(1)` for the most important pane. ```swift import SwiftUI struct MainView: View { @EnvironmentObject var store: Store var body: some View {...
Note that - Explicit `id` is needed, although Book already conforms to Identifiable - `selection` needs a default value ```swift class BookViewModel: ObservableObject { @Published var books: [Book] = []...
Sometimes we don't want to show progress view right away ```swift HUDProgressView() .transition( AnyTransition.asymmetric( insertion: AnyTransition.opacity.animation(Animation.default.delay(1)), removal: AnyTransition.opacity) ) ```
For many apps that require user authentication, a common practice is to define a shared `UserManager` with an optional `User`. This is convenient but it requires us to constantly unwrap...
Make it easy to access common cases, for example `UserDefaults` ```swift extension UserDefaults { enum Key: String { case hasBackup } subscript(key: Key) -> Bool { get { bool(forKey: key.rawValue)...
Over the course of making several SwiftUI apps, I've discovered quite a few hidden magic of SwiftUI that are quite fun. Here are 6 interesting SwiftUI features in View Builder...
When a function expects `AnyPublisher` but in mock, we have `Just` ```swift func getBooks() -> AnyPublisher { return Just([ Book(id: "1", name: "Book 1"), Book(id: "2", name: "Book 2"), ])...