小编Nas*_*296的帖子

JSON解析Swift 3

有没有人能够找到一种方法来解析Swift 3中的JSON文件?我已经能够返回数据但是在将数据分解为特定字段时我没有成功.我会发布示例代码,但我已经通过这么多不同的方法失败了,并没有保存任何.我要解析的基本格式是这样的.提前致谢.

{
  "Language": {

    "Field":[
          {
          "Number":"976",
          "Name":"Test"
          },
          {
          "Number":"977",
          "Name":"Test"
          }
       ]
   }
}
Run Code Online (Sandbox Code Playgroud)

xcode parsing json swift

21
推荐指数
2
解决办法
5万
查看次数

路径线的圆角 SwiftUI

如何制作一条末端为圆形的线?我正在画一条简单的直线,如下所示,但不能把两端弄圆。“.cornerRadius”不起作用。有任何想法吗?

struct Line: View {
    let geoProx: GeometryProxy

    var body: some View {
        Path{ path in
            path.move(to: CGPoint(x: geoProx.size.width/2, y: geoProx.size.height/2))
            path.addLine(to: CGPoint(x: geoProx.size.width/2 - geoProx.size.width/4, y: geoProx.size.height/2))

        }
        .stroke(lineWidth: 8.0)
        .foregroundColor(.white)
        .cornerRadius(10.0)
        .zIndex(1.5)
    }
}
Run Code Online (Sandbox Code Playgroud)

iphone ios swift swiftui

11
推荐指数
1
解决办法
2272
查看次数

为什么我不能在函数Swift中使用self

我正在尝试将SKSpriteNodes添加到函数中的视图中,但Xcode不允许我这样做.它给了我错误"使用未解析的标识符'self'"

 func indicate() {
if test == 0 {
    var large = ((CGFloat(largest)*54) - 29) - selectedNode.position.x
    var small = selectedNode.position.x - ((CGFloat(smallest)*54) - 29)

    indicatorRight.position = CGPointMake(selectedNode.position.x + large, selectedNode.position.y)
    indicatorRight.userInteractionEnabled = true
    indicatorRight.zPosition = 0.5

    indicatorLeft.position = CGPointMake(selectedNode.position.x - small, selectedNode.position.y)
    indicatorLeft.userInteractionEnabled = true
    indicatorLeft.zPosition = 0.5


    println(indicatorLeft.position)
    //  println(smallest)
    self.addChild(indicatorRight)
    self.addChild(indicatorLeft)

    }


}
Run Code Online (Sandbox Code Playgroud)

swift

6
推荐指数
2
解决办法
9079
查看次数

标签 统计

swift ×3

ios ×1

iphone ×1

json ×1

parsing ×1

swiftui ×1

xcode ×1