最新发布第20页
排序
Bottom Navigation
创建 Screen HomeScreen 的可组合函数 @Composable fun HomeScreen() { Column( modifier = Modifier.fillMaxSize(), horizontalAlignment = Alignment.CenterHorizontally ) { Button( onClick...
Day 15 – 咖啡机
MENU = { 'espresso': { 'ingredients': { 'water': 50, 'coffee': 18, }, 'cost': 1.5, }, 'latte': { 'ingredients': { 'water': 200, 'milk': 150, 'coffee': 24, }, 'cost': 2.5, }, 'cappu...
如何动态更改查询的排序顺序或谓词
要实现动态排序,您需要将@Query属性移至 SwiftUI 层次结构中的视图中 - 您需要将其放入子视图中,在其中可以使用依赖项注入提供排序值。 这意味着创建一个新的 SwiftUI,它使用@Query来显示您...
How to create and call an async function如何创建和调用异步函数
Using async functions in Swift is done in two steps: declaring the function itself as being async, then calling that function using await.在 Swift 中使用异步函数分两步完...
What’s the difference between await and async let? await 和 async let 有什么区别?
Swift lets us perform async operations using both await and async let, but although they both run some async code they don’t quite run the same: await wai...
How to create continuations that can throw errors 如何创建可以抛出错误的continuations
Swift provides withCheckedContinuation() and withUnsafeContinuation() to let us create continuations that can’t throw errors, but if the API you’re using ...
How to manipulate an AsyncSequence using map(), filter(), and more 如何使用 map()、filter() 等作 AsyncSequence
AsyncSequence has implementations of many of the same methods that come with Sequence, but how they operate varies: some return a single value that fulfills you...
What’s the difference between actors, classes, and structs? Actors、Classes和 Structs 之间有什么区别?
Swift provides four concrete nominal types for defining custom objects: actors, classes, structs, and enums. Each of these works a little differently from the others, but the first...
How to handle concurrency errors in unit tests 如何处理单元测试中的并发错误
Both Swift Testing and XCTest give us three main options for handling errors in tests: we can consider them immediate failures, we can handle them internally and make our own asser...





