NSTimer Xcode 警告

发布于 2024-11-10 06:35:21 字数 186 浏览 7 评论 0原文

我有一个 NSTimer,我用 scheduledTimerWithTimeInterval: 初始化,时间间隔很短(0.1 秒),没有重复,然后再也不会使用它,因为它会自行失效,因此释放其对目标的保留。 Xcode 警告它是一个未使用的变量,我很好奇是否有一种明智的方法可以消除该警告(黄色让我眼花缭乱!)

谢谢。

I have an NSTimer that I initialize with scheduledTimerWithTimeInterval: with a very short interval (.1 seconds) with no repeat, and then never use it again as it invalidates itself and therefore releases its retain on the target. Xcode warns that it is an unused variable, and I was curious if there was a sensible way to get rid of the warning (The yellow upsets my eyeballs!)

Thanks.

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

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

发布评论

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

评论(2

绿萝 2024-11-17 06:35:21

如果您不再使用它,请不要将其保存在变量中。

[NSTimer scheduledTimerWithTimeInterval:0.4 target:self selector:@selector(timer:) userInfo:nil repeats:NO];

会工作得很好

if you don't use it again don't save it in a variable.

[NSTimer scheduledTimerWithTimeInterval:0.4 target:self selector:@selector(timer:) userInfo:nil repeats:NO];

will work perfectly fine

天赋异禀 2024-11-17 06:35:21

如果您不打算使用返回值,请不要将结果分配给任何内容。

[NSTimer scheduledTimerWithTimeInterval:...];

Just don't assign the result to anything if you aren't going to use the return value.

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