小编Kar*_*rim的帖子

如何在 SwiftUI 中使用函数返回 ToolbarItem?

我是 SwiftUI 的新手,我尝试将额外的代码放入函数中,但收到一些错误消息,但我不知道如何修复:

'some' types are only implemented for the declared type of properties and subscripts and the return type of functions

我的代码:

func test() -> ToolbarItem<Void, some View> {
   return ToolbarItem(direction: .right) {
        Label("", systemImage: "icloud.and.arrow.up.fill")
            .foregroundColor(.white)
            .frame(width: itemWith, height: 30, alignment: .center)
   }
}
Run Code Online (Sandbox Code Playgroud)

有谁知道如何做到这一点?谢谢

swift swiftui

7
推荐指数
2
解决办法
1908
查看次数

快速 JSONDecoder 不起作用

我观看了 WWDC session 102 并尝试使用 JSONDecoder 进行建模,但我有一个问题,这是我的结构

public struct DataListResult:Codable{
    let _id : String
    let createdAt : String
    let desc : String
    let images : Array<String>
    let publishedAt : String
    let source : String
    let type : String
    let url : String
    let used : Int
    let who : String
}

public struct DataListModel:Codable{

    let results : [DataListResult]
    let error: Bool
}
Run Code Online (Sandbox Code Playgroud)

JSON:

{
  "results" : [
    {
      "_id" : "59266a79421aa92c73b6475c",
      "images" : [
        "http:\/\/img.gank.io\/875a9508-3a1e-4d4b-8b91-c111ea62871a"
      ],
      "source" : "chrome",
      "who" …
Run Code Online (Sandbox Code Playgroud)

ios swift

4
推荐指数
1
解决办法
5693
查看次数

标签 统计

swift ×2

ios ×1

swiftui ×1