在 xCode 7.3 上弃用了 For 循环
For loop deprecated on xCode 7.3
我意识到旧系统不推荐使用 for 循环,但一直无法弄清楚问题出在哪里。我在 objective 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"];
}
C 风格的 for 循环在 Swift 中被弃用,而不是在 Objective C 中。 Objective C 是 C 的超集,符合 C 标准,所以 C 风格的 for 循环永远不会消失,尤其是苹果最近没有发布很多 Objective C 变化。
我意识到旧系统不推荐使用 for 循环,但一直无法弄清楚问题出在哪里。我在 objective 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"];
}
C 风格的 for 循环在 Swift 中被弃用,而不是在 Objective C 中。 Objective C 是 C 的超集,符合 C 标准,所以 C 风格的 for 循环永远不会消失,尤其是苹果最近没有发布很多 Objective C 变化。