Post

Replies

Boosts

Views

Activity

C-Style for statement has been removed in swift 3
hi,I update my xcode(xcode 7.3.1 to xcode 8.3.3), the i have been experienced an error "c-style for statement has been removed in swift3". How to convert the belowcode in to swift3.1.fileprivate func drawXGrid() { x.grid.color.setStroke() let path = UIBezierPath() var x1: CGFloat let y1: CGFloat = self.bounds.height - y.axis.inset let y2: CGFloat = y.axis.inset let (start, stop, step) = self.x.ticks for var i: CGFloat = start; i <= stop; i += step { //c-style for statement has been removed in swift3 x1 = self.x.scale(i) + x.axis.inset path.move(to: CGPoint(x: x1, y: y1)) path.addLine(to: CGPoint(x: x1, y: y2)) } path.stroke() }fileprivate func drawYLabels() { var yValue: CGFloat let (start, stop, step) = self.y.ticks for var i: CGFloat = start; i <= stop; i += step { //c-style for statement has been removed in swift3 yValue = self.bounds.height - self.y.scale(i) - (y.axis.inset * 1.5) let label = UILabel(frame: CGRect(x: 0, y: yValue, width: y.axis.inset, height: y.axis.inset)) label.font = UIFont.preferredFont(forTextStyle: UIFontTextStyle.caption2) //c-style for statement has been removed in swift label.textAlignment = .center label.text = String(Int(round(i))) self.addSubview(label) } }How to convert the above for loop into swift 3.1. what shall i do to remove the error message.
3
0
3.1k
Jul ’17