我意识到for循环被旧系统弃用了,但是还没弄清楚问题是什么..我已经在目标c中创建了for循环现在我想知道这是否与引入xCode 7.3方式实现for循环是否已弃用。如果答案是你可以给我一个关于如何不弃用的循环的例子?但我无法理解我的错误在哪里
for (NSInteger i = 0; i < self.valueForBar.count; i++ ) {
// Creazione delle barre in movimento
CGFloat columnWidth = 25;
CGFloat maximumValueOfBar = self.frame.size.height;
CGFloat index = [[self.valueForBar objectAtIndex:i] floatValue] /100;
CGFloat barWidth = 20;
UIBezierPath *path = [UIBezierPath bezierPath];
[path moveToPoint:CGPointMake(15 +columnWidth *i,maximumValueOfBar -25)];
[path addLineToPoint:CGPointMake(15 +columnWidth *i,(maximumValueOfBar -25) - maximumValueOfBar * index)];
CAShapeLayer *pathLayer = [CAShapeLayer layer];
pathLayer.frame = self.scrollChart.bounds;
pathLayer.path = path.CGPath;
pathLayer.strokeColor = self.fillBarColor.CGColor;
pathLayer.fillColor = nil;
pathLayer.lineWidth = barWidth;
pathLayer.lineJoin = kCALineJoinBevel;
[self.scrollChart.layer addSublayer:pathLayer];
CABasicAnimation *pathAnimation = [CABasicAnimation animationWithKeyPath:@"strokeEnd"];
pathAnimation.duration = 1;
pathAnimation.fromValue = [NSNumber numberWithFloat:0.0f];
pathAnimation.toValue = [NSNumber numberWithFloat:1.0f];
[pathLayer addAnimation:pathAnimation forKey:@"strokeEnd"];
}
答案 0 :(得分:1)
循环的C样式在Swift中不推荐使用,而不是在Objective C中。目标C是C的超级集合并且符合C标准,因此循环的C样式永远不会消失,特别是因为Apple不发布这些天很多目标C发生了变化。