当前位置:网站首页>Added the ability of class @published for @cloudstorage
Added the ability of class @published for @cloudstorage
2022-07-28 14:39:00 【Dongpo Pig Knuckle】
I revised it again CloudStorage Code for , Now we can AppStorage Exactly the same will UserDefaults and NSUbiquitousKeyValueStore Put it all together , stay SwiftUI In the United Management of .
Next week we will talk about its implementation —— 【 How to add classes to attribute wrappers Published The ability of 】
class Settings:ObservableObject {
@AppStorage("name") var name = "fat"
@AppStorage("age") var age = 5
@CloudStorage("readyForAction") var readyForAction = false
@CloudStorage("speed") var speed: Double = 0
}
struct DemoView: View {
@StateObject var settings = Settings()
var body: some View {
Form {
TextField("Name",text: $settings.name)
TextField("Age", value: $settings.age, format: .number)
Toggle("Ready", isOn: $settings.readyForAction)
.toggleStyle(.switch)
TextField("Speed",value: $settings.speed,format: .number)
}
.frame(width: 400, height: 400)
}
}
CloudStorage The original author has not merged the modified code , Now you can download my Fork edition [1].
About NSUbiquitousKeyValueStore see also stay SwiftUI Next use NSUbiquitousKeyValueStore Synchronous data [2]
About AppStorage You can read @AppStorage Research [3]
Because the articles in wechat official account can only be modified 10 Characters , So only blog posts www.fatbobman.com Will keep updating , See forgiveness .
Reference material
[1] Fork edition : https://github.com/fatbobman/CloudStorage
[2] stay SwiftUI Next use NSUbiquitousKeyValueStore Synchronous data : https://www.fatbobman.com/posts/nsubiquitousKeyvalueStore/
[3] @AppStorage Research : https://fatbobman.com/posts/appstorage/
边栏推荐
- Revised version | target detection: speed and accuracy comparison (faster r-cnn, r-fcn, SSD, FPN, retinanet and yolov3)
- Using reflection to build a menu spanning tree
- What is gossip (E-Net gossip)
- 8、 Picker usage drop-down box selection effect
- Realization of chat room function
- 树莓派基础 | 总结记录树莓派学习过程中的一些操作
- pix2pix
- Hcip day 11
- 如何让照片中的人物笑起来?HMS Core视频编辑服务一键微笑功能,让人物笑容更自然
- 企鹅一面:为什么不建议使用SELECT * ?
猜你喜欢

UI开发中所遇到的各种坑

MQTT入门级简单介绍与使用
![[ecmascript6] set and map](/img/64/dd6ffc5f0faf881b990e609cf62343.png)
[ecmascript6] set and map

如何有效进行回顾会议(上)?

Hcip day 10

2022 high altitude installation, maintenance, removal of examination question bank and online simulated examination

Bulk Rename Utility

@DS('slave') 多数据源兼容事务问题解决方案

国产数据库的红利还能“吃”多久?

How to use the C language library function getchar ()
随机推荐
MQTT入门级简单介绍与使用
Leetcode 0142. circular linked list II
[leetcode] 1331. Array sequence number conversion
分集技术简略
2022 melting welding and thermal cutting examination questions and online simulation examination
2022年熔化焊接与热切割考题及在线模拟考试
Floating point data type in C language (did you learn to waste it)
C语言实现简单学生成绩管理系统的方法
为 @CloudStorage 添加了类 @Published 的能力
【七夕】七夕孤寡小青蛙究极版?七夕节最终章!
Using reflection to build a menu spanning tree
Core Data 是如何在 SQLite 中保存数据的
2022高处安装、维护、拆除考试题库及在线模拟考试
Cv:: mat conversion to qimage error
如何有效进行回顾会议(上)?
String转为long 类型报错原因:要转为long必须是int、double、float型[通俗易懂]
Open source project - taier1.2 release, new workflow, tenant binding simplification and other functions
如何只降3D相机不降UI相机的分辨率
QQ robot configuration record based on nonebot2
如何有效进行回顾会议(上)?