我正在使用Firebase 数据库 REST API和 JSONDecoder/JSONEncoder。到目前为止,它一直运行良好。但是,对于删除数据,预期返回的响应是null
,而 JSONDecoder 似乎不太喜欢那样。
这是我通过 Postman 发送的查询类型以及我返回的内容(不包括敏感数据)。
DELETE /somedata/-LC03I3oHcLhQ/members/ZnWsJtrZ5UfFS6agajbL2hFlIfG2.json
content-type: application/json
cache-control: no-cache
postman-token: ab722e0e-98ed-aaaa-bbbb-123f64696123
user-agent: PostmanRuntime/7.2.0
accept: */*
host: someapp.firebaseio.com
accept-encoding: gzip, deflate
content-length: 39
HTTP/1.1 200
status: 200
server: nginx
date: Thu, 02 Aug 2018 21:53:27 GMT
content-type: application/json; charset=utf-8
content-length: 4
connection: keep-alive
access-control-allow-origin: *
cache-control: no-cache
strict-transport-security: max-age=31556926; includeSubDomains; preload
null
Run Code Online (Sandbox Code Playgroud)
如您所见,响应代码是200
,正文是null
。
当我收到响应时,这是我得到的错误:
Swift.DecodingError.dataCorrupted(Swift.DecodingError.Context(codingPath: [], debugDescription: "The given data is not …
OutlineGroup
我最近在 iOS 14 中发现了 SwiftUI (我使用的是 Xcode 12 beta 6 )。无论是单独使用还是使用时,它都非常有效,List
可以根据需要从树形结构、已识别数据的底层集合中计算视图和披露组。
也就是说,如果您有一个递归定义,那么这对于构建元素struct
来说非常有效。DisclosureGroup
然而,我正在寻找一些稍微不同的东西,让我能够构建一个“下拉”(或汉堡包)菜单。
在 iOS 14 中,还有另一个名为 的控件Menu
,它可以完全按照我想要的方式呈现“下拉”(或汉堡)菜单:
然而,我似乎无法将两者一起使用来构建Menu
基于递归表示的数据的动态,例如:
struct Tree<Value: Hashable>: Hashable {
let value: Value
var children: [Tree]? = nil
}
Run Code Online (Sandbox Code Playgroud)
菜单按以下方式构建:
struct SideMenu: View {
var body: some View {
Menu {
Button(action: {}) {
Image(systemName: "person")
.foregroundColor(.gray)
.imageScale(.large)
Text("Profile")
.foregroundColor(.gray)
.font(.headline)
}
Button(action: {}) {
Image(systemName: "person.3")
.foregroundColor(.gray)
.imageScale(.large)
Text("Family Members")
.foregroundColor(.gray)
.font(.headline) …
Run Code Online (Sandbox Code Playgroud)