gpt4 book ai didi

iphone - 为什么 Xcode 4 将变量标记为未使用,即使它们是?

转载 作者:太空狗 更新时间:2023-10-30 03:46:40 25 4
gpt4 key购买 nike

我正在实例化和调度一个计时器变量,但 Xcode 编译器和分析器用 2 个警告标记我的变量“levelScoreTimer”,例如“警告:未使用的变量‘levelScoreTimer’和‘死存储:在初始化期间存储到‘levelScoreTimer’的值是从来没有读过”。我的声明有什么问题? scheduledTimerWithTimeInterval 方法实例化计时器并将其放在主运行循环中。我还在内部的选择器方法中停止计时器,因此肯定会使用计时器作为对象。有时类似案例我通过在第一行声明变量类型并在第二行进行赋值来将行分成两行。但这不是计时器对象的解决方案。有什么建议吗?这是我的声明和赋值:

NSTimer *levelScoreTimer = [NSTimer scheduledTimerWithTimeInterval:0.1 target:self selector:@selector(updateTotalScoreLabelFromTimeLeftLabel:) userInfo:nil repeats: YES];

最佳答案

更改代码从

NSTimer *levelScoreTimer = [NSTimer scheduledTimerWithTimeInterval:0.1 target:self selector:@selector(updateTotalScoreLabelFromTimeLeftLabel:) userInfo:nil repeats: YES];

[NSTimer scheduledTimerWithTimeInterval:0.1 target:self selector:@selector(updateTotalScoreLabelFromTimeLeftLabel:) userInfo:nil repeats: YES];

关于iphone - 为什么 Xcode 4 将变量标记为未使用,即使它们是?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7009925/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com