'inout [int]'(又名'inout Array <int>')不能转换为'Array <element>'

时间:2016-03-13 11:02:31

标签: arrays swift swift2

代码是将活动数据存储到条形图中,但是,最后一行标记了我从未遇到过的错误。

代码:

var days:[String] = []
var stepsTaken:[Int] = []
let activityManager = CMMotionActivityManager()
let pedoMeter = CMPedometer()

let formatter = NSDateFormatter()
        formatter.dateFormat = "d MMM"
        dispatch_sync(serialQueue, { () -> Void in
            let today = NSDate()
            for day in 0...6{
let fromDate = NSDate(timeIntervalSinceNow: Double(-7+day) * 86400)
let toDate = NSDate(timeIntervalSinceNow: Double(-7+day+1) * 86400)
let dtStr = formatter.stringFromDate(toDate)
    self.pedoMeter.queryPedometerDataFromDate(fromDate, toDate: toDate) { data, error in
                  if let data = data {
                  if(error == nil){
                      print("\(dtStr) : \(data.numberOfSteps)")
                      self.days.append(dtStr)
                      self.stepsTaken.append(Int(data.numberOfSteps))
                      print("Days :\(self.days)")
                      print("Steps :\(self.stepsTaken)")

                  if(self.days.count == 7){
                    dispatch_sync(dispatch_get_main_queue(), { () -> Void in
                         let xVals = self.days
                         var yVals: [BarChartDataEntry] = []
                         for idx in 0...6 {
                              yVals.append(BarChartDataEntry(value: Float(self.stepsTaken[idx]), xIndex: idx))
                                }

0 个答案:

没有答案