“bezierPathWithOvalInRect”参数1的不兼容类型错误

时间:2022-12-11 20:25:04

I have the following code:

我有以下代码:

- (void)drawRect:(NSRect)dirtyRect 
{
   [[NSBezierPath bezierPathWithOvalInRect:[self theRect]] stroke];
}

- (NSRect)theRect
{
   return NSMakeRect(1, 1, 1, 1); // made up some values
}

When I compile it says "Incompatible type for argument 1 of 'bezierPathWithOvalInRect' error". When I do this, however, it works:

当我编译它时说“'bezierPathWithOvalInRect'错误的参数1的不兼容类型”。但是,当我这样做时,它的工作原理是:

- (void)drawRect:(NSRect)dirtyRect 
{
   NSRect theRect = NSMakeRect(1, 1, 1, 1);
   [[NSBezierPath bezierPathWithOvalInRect:theRect] stroke];
}

What is problem?

有什么问题?

Thanks.

谢谢。

1 个解决方案

#1


2  

Did you put - (NSRect)theRect in your header?

你把 - (NSRect)theRect放在标题中了吗?

Also does it say your program might not respond to -theRect?

它也说你的程序可能不响应-theRect?

#1


2  

Did you put - (NSRect)theRect in your header?

你把 - (NSRect)theRect放在标题中了吗?

Also does it say your program might not respond to -theRect?

它也说你的程序可能不响应-theRect?