I would like to add a label for each bracket made. I am getting “Reciever type ‘draw 2D’ (my class) for instance message does not declare a method with selector ‘addSubView'” for the second to last line. And I am getting “ARC forbids explicit message send of ‘release'” for the last line.
Here is my code:
for (int i = 0; i < 4; i++) {
CGFloat bracketStartX = 50;
CGFloat bracketEndX = 200;
CGFloat bracketStartY = 25 + (i * height / 4);
CGFloat bracketEndY = 80 + (i * height / 4);
CGContextMoveToPoint(context, bracketStartX, bracketStartY);
//make bracket
CGContextAddLineToPoint(context, bracketEndX, bracketStartY);
CGContextAddLineToPoint(context, bracketEndX, bracketEndY);
CGContextAddLineToPoint(context, bracketStartX, bracketEndY);
CGContextMoveToPoint(context, bracketEndX, (bracketEndY + bracketStartY)/2 );
CGContextAddLineToPoint(context, bracketEndX + 50, (bracketEndY + bracketStartY)/2);
UILabel *label = [[UILabel alloc] initWithFrame: CGRectMake(bracketStartX + 5, bracketStartY - 5, 20, 15)];
label.text = @"text"; //etc...
[self addSubView:label];
[label release];
}
Thanks.
[self addSubview]; // lowercase vIf you’re using ARC, do not
releaseyour objects.