0

I'm using coreGraphic to draw the line .. So far so good ... I can very well create a line the problem is that I can not multiply them by the number of objects inserted into an array.

To do this I have created a for loop but always visualize a line ... can you help me?

CGContextRef context = UIGraphicsGetCurrentContext();

for (int i = 0; i < 100; i++ ) {

    CGContextMoveToPoint(context, 20, 20);
    CGContextAddLineToPoint(context, 20, self.frame.size.height -20);

    CGContextSetStrokeColorWithColor(context, [[UIColor whiteColor] CGColor]);
}

    CGContextStrokePath(context);
Swift Dev Journal
  • 19,282
  • 4
  • 56
  • 66
kAiN
  • 2,559
  • 1
  • 26
  • 54
  • First of all this kind of for loop is deprecated. Use For in loop for i in 0 ..< 100{ } And aslo, You are looping but drawing the line from same initial point(20,20) to (self.frame.size.height - 20 ).. it will draw same path again and again.. – Samip Shah Dec 07 '16 at 05:04
  • http://stackoverflow.com/questions/41012304/for-loop-deprecated-on-xcode-7-3 Hello I did not understand where is my mistake ... My for loop has always worked and now it seems deprecated. I created a question about stackover to understand where is my mistake and to make non-deprecated my cycle for .. You could look at it? Thanks so much – kAiN Dec 07 '16 at 08:11
  • Sorry bro, i did not realised it was objective c code.. c style for loop is deprecated in lastest swift not in objective c. – Samip Shah Dec 07 '16 at 08:26
  • No problem bro! So my code is correct? : D – kAiN Dec 07 '16 at 08:27
  • i have a question , I didn't got i thing, why are you drawing same line again again for 100 times. – Samip Shah Dec 07 '16 at 08:29
  • That was an example for loop .. the values ​​would change later ... In this question show the code I used to achieve my goal and it works perfectly: D. I am building a Bar Chart http://stackoverflow.com/questions/41012304/for-loop-deprecated-on-xcode-7-3 – kAiN Dec 07 '16 at 08:32

0 Answers0