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

发布于 2024-08-20 02:16:43 字数 503 浏览 7 评论 0原文

我有以下代码:

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

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

当我编译时,它显示“‘bezierPathWithOvalInRect’错误的参数 1 的类型不兼容”。然而,当我这样做时,它起作用了:

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

问题是什么?

谢谢。

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:

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

What is problem?

Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

一枫情书 2024-08-27 02:16:43

您是否将 - (NSRect)theRect 放入标题中?

它还说您的程序可能不会响应 -theRect 吗?

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

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文