Search code examples
iosobjective-cquartz-graphics

Setting the line cap of a CAShapeLayer


I'm having a really weird error pop up when I try to run one line of code.

I have a subclass of CAShapeLayer, on which I am trying to set the line cap style. I want to use the round cap style, but when I add this code:

[self setLineCap: kCGLineCapRound];

The build fails and I get this error and warning:

Implicit conversion of 'int' to 'NSString *' is disallowed with ARC

Incompatible integer to pointer conversion sending 'int' to parameter of type 'NSString *'

But if I add this:

[self setLineCap: kCGLineCapButt];

It builds just fine. Why is it breaking on the other line cap type? Is this a problem/bug with Quartz?


Pertinent info.

  • iOS SDK 8.1
  • Xcode 6.1.1
  • Deployment Target iOS 7.0

Solution

  • CAShapeLayer uses kCALineCap*** which is a defined constant string in the CAShapeLayer.h file, and not a kCGLineCap*** which is part of an enum.