1.29 SwiftUI学习笔记

1.Form

A container for grouping controls used for data entry, such as in settings or inspectors.

对用于数据输入的控件(如设置或检查器)进行分组的容器

用法:

var body: some View {
        Form {
            Section(header: Text("Notifications")) {
                Picker("Notify Me About", selection: $notifyMeAbout) {
                    Text("Direct Messages").tag(NotifyMeAboutType.directMessages)
                    Text("Mentions").tag(NotifyMeAboutType.mentions)
                    Text("Anything").tag(NotifyMeAboutType.anything)
                }
                Toggle("Play notification sounds", isOn: $playNotificationSounds)
                Toggle("Send read receipts", isOn: $sendReadReceipts)
            }
            Section(header: Text("User Profiles")) {
                Picker("Profile Image Size", selection: $profileImageSize) {
                    Text("Large").tag(ProfileImageSize.large)
                    Text("Medium").tag(ProfileImageSize.medium)
                    Text("Small").tag(ProfileImageSize.small)
                }
                Button("Clear Image Cache") {}
            }
        }
    
}

2.Future

A publisher that eventually produces a single value and then finishes or fails.

最终生成单个值,之后成功或失败 的 发布者

Future.Promise

A type that represents a closure to invoke in the future, when an element or error is available.、当元素或错误可用时,表示将来要调用的闭包 的类型

typealias Promise = (Result<Output, Failure>) -> Void

3.eraseToAnyPublisher() 

用来将类型擦除,最后得到一个AnyPublisher类型的发布者

​
func eraseToAnyPublisher() -> AnyPublisher<Self.Output, Self.Failure>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值