最新发布第21页
Day 7 - 猜单词游戏-Stewed Noodles 资源

Day 7 – 猜单词游戏

猜单词游戏的基本业务流程如下所示 生成单词,检测答案 生成随机单词,并检测用户输入的单词是否在选定的单词中 import random word_list = ['aardvark', 'baboon', 'camel'] chosen_word = ran...
jiulinxiri的头像-Stewed Noodles 资源烩之面大会员jiulinxiri11个月前
0100
Widget 的 Container Background-Stewed Noodles 资源

Widget 的 Container Background

Widget 的 Container Background(容器背景) 是在 iOS 17 中引入的。在 Widget 的开发过程中,可能会在预览中遇到如下的错误 Widget needs to adopt container background. 容器背景用途 iOS 1...
jiulinxiri的头像-Stewed Noodles 资源烩之面大会员jiulinxiri9个月前
0100
使用 @Model 宏定义模型-Stewed Noodles 资源

使用 @Model 宏定义模型

您将使用 @Model 宏来定义所有 SwiftData 模型类。该宏会自动使您的类能够从 SwiftData 加载和存储数据,支持观察更改,并添加 Hashable、Identifiable、Observable 和 PersistentModel 的遵循...
jiulinxiri的头像-Stewed Noodles 资源烩之面大会员jiulinxiri9个月前
0100
What’s the difference between await and async let? await 和 async let 有什么区别?-Stewed Noodles 资源

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-Stewed Noodles 资源

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-Stewed Noodles 资源

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...
How to handle different result types in a task group 如何处理任务组中的不同结果类型-Stewed Noodles 资源

How to handle different result types in a task group 如何处理任务组中的不同结果类型

Each task in a Swift task group must return the same type of data as all the other tasks in the group, which is often problematic – what if you need one task group to handle ...
Introduction to testing Swift concurrency Swift 并发测试简介-Stewed Noodles 资源

Introduction to testing Swift concurrency Swift 并发测试简介

Swift's full range of concurrency features work great with unit tests using both the legacy XCTest framework and the new Swift Testing framework.Swift 的全套并发功能非常适合使用旧...
How to test AsyncSequence and AsyncStream 如何测试 AsyncSequence 和 AsyncStream-Stewed Noodles 资源

How to test AsyncSequence and AsyncStream 如何测试 AsyncSequence 和 AsyncStream

Concurrent Swift code often streams values over time rather than returning them all at once, so it's important to be able to write tests to check an AsyncStream, AsyncSeq...
How to set a time limit for concurrent tests 如何为并发测试设置时间限制-Stewed Noodles 资源

How to set a time limit for concurrent tests 如何为并发测试设置时间限制

Both Swift Testing and XCTest have simple mechanisms for controlling how long tests should be allowed to run before being considered a failure. This is critically important for con...