使用swift

时间:2019-06-08 09:43:56

标签: ios swift logic

Swift 5 iOS 12.x

我确定是一个愚蠢的问题,但是我有片刻。

我得到的值介于-100到100之间。我对小于-10或大于10的值感兴趣。我编写了这段代码。

func returnPod() -> String {
defer {
   pods.removeAll()
}
var aPitch: Float? = 0
var aRoll: Float? = 0
var aYaw: Float? = 0
for peas in pods {
  print("peas \(peas)")
  if peas.pitch! < Float(-10) && peas.pitch! > Float(10) {
      // capture an average everything below 10, above 10
      aPitch = aPitch! + peas.pitch!
      aRoll = aRoll! + peas.roll!
      aYaw = aYaw! + peas.yaw!
  } else {
      // drop everything return zero this should happen if pitch is between -10 and 10.
    return "@:0:0:0\n"
  }
}
return("@:\(String(describing: aRoll!)):\(String(describing: aPitch!)):\(String(describing: aYaw!))")

}

但是它不起作用,它只会返回所有内容...我在做什么错了。

0 个答案:

没有答案