I have downloaded Cor开发者_运维问答ePlot a week ago and have included in one of my MAC application projects. Everything works fine in Debug but when I try to build it using Distribution build it fails with this error "incompatible type for argument 1 of initWithFrame"
Here is where it is happening...
pieChart = [[CPXYGraph alloc] initWithFrame:CGRectZero];
If this is for a Mac OS X application, unlike UIKit, Application Kit generally takes geometry from NS* structures. So, you want NSZeroRect, not CGRectZero. Also, when you generate these structures, you'll want to use the macro NSMakeRect(x, y, w, h)
rather than the CoreGraphics CGRectMake(x, y, w, h)
.
CPXYGraph
is a CALayer
, so CGRectZero
is correct. The problem is that more than one class has an -initWithFrame:
method. +alloc
returns an id
so the compiler doesn't know which class to choose and sometimes it picks the wrong one. You can solve this with a type cast, like this:
pieChart = [(CPXYGraph *)[CPXYGraph alloc] initWithFrame:CGRectZero];
精彩评论