Publisher
发布者向一个或多个订阅者发送值。它们遵循Publisher
协议,并声明输出的类型和它们产生的任何错误:
1 | public protocol Publisher { |
发布者可以随时间发送任意数量的值,也可以发送错误而失败。关联类型Output
定义发布者可以发送哪些类型的值,而关联类型Failure
定义它可能失败的错误类型。发布者可以通过指定never
关联类型来声明它永远不会失败。
发布者向一个或多个订阅者发送值。它们遵循Publisher
协议,并声明输出的类型和它们产生的任何错误:
1 | public protocol Publisher { |
发布者可以随时间发送任意数量的值,也可以发送错误而失败。关联类型Output
定义发布者可以发送哪些类型的值,而关联类型Failure
定义它可能失败的错误类型。发布者可以通过指定never
关联类型来声明它永远不会失败。
通过组合 事件处理操作符 自定义异步事件的处理。
Customize handling of asynchronous events by combining event-processing operators.
SwiftUI’s reactive state management makes this a lot easier by introducing the notion of a source of truth
that can be shared across your app using SwiftUI’s property wrappers such as @EnvironmentObject
, @ObservedObject
, and @StateObject
the notion of a source of truth 事实源
This source of truth usually is your in-memory data model
In this series, we will look at how to use Combine in the context of SwiftUI to
A scene contains the view hierarchy of your app.
1 | import SwiftUI |
In this sample, body returns the primary scene WindowGroup
, which describes the view hierarchy of the sample’s main window.
WindowGroup: It provides platform-specific behaviors for your app, such as supporting multiple windows in macOS and iPadOS.
The computed body
property can return one or more primary and secondary scenes.
The @main attribute identifies the app’s entry point.
1 | import SwiftUI |
The entry point is responsible for the start up of the app.
The MyApp structure conforms to the App protocol
,
The structure implements the computed property body
, which is a requirement of the App protocol
.
SwiftUI provides different types of scenes including WindowGroup
, Window
, DocumentGroup
, and Settings
一些在后台运行的任务,需要在特定条件下对用户发起通知,如果有跨端要求,可以用第三方库,不过需要付费,优势在于可同时兼容移动端和桌面端,这里只是个人使用,所以推荐使用Mac自带Apple Script来添加,本来考虑通过向Reminders
添加Event
的方式,实现Mack & iOS同时提醒,不过只找到OC和Swift的API,没找到Py的API
机器学习是人工智能的一个分支。人工智能的研究历史有着一条从以“推理”为重点,到以“知识”为重点,再到以“学习”为重点的自然、清晰的脉络。
机器学习是实现人工智能的一个途径之一,即以机器学习为手段,解决人工智能中的部分问题。
环境:
Mac OS Monterey 12.5.1
MacBook Air (M1, 2020)
Xcode 14.1
Python 3.11.5