For循环在xCode 7.3上不推荐使用 [英] For loop deprecated on xCode 7.3

查看:193
本文介绍了For循环在xCode 7.3上不推荐使用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我意识到for循环被旧系统弃用,但一直无法弄清楚是什么问题。我创建了这个循环在目标c现在我想知道这是否与引入xCode 7.3方式执行for循环是否被弃用。如果答案是你可以给我一个这个我的周期如何使不被弃用的例子吗?然而,我不明白我的错误在哪里
$ b $ pre $ for(NSInteger i = 0; i< self.valueForBar.count; i ++ ){


// movimento中的Creazione delle barre

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];

$ b


解决方案

for循环在Swift中不推荐使用,而不在Objective C中。Objective C是C的超集,符合C标准,因此C风格for循环永远不会消失,特别是因为Apple没有释放很多Objective C的变化天。


I realized that for loops are deprecated with the old system but have not been able to figure out what the problem is .. I've created this for loop in objective c now I would like to know if this with the introduction of xCode 7.3 way implement the for loop is deprecated or not. If the answer is you could give me an example of this my cycle on how to make non-deprecated? Yet I could not understand where is my mistake

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 style for loops are deprecated in Swift, not in Objective C. Objective C is a super set of C and conforms to the C standard, so the C style for loop is never going away, especially since Apple doesn't release many Objective C changes these days.

这篇关于For循环在xCode 7.3上不推荐使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆