gpt4 book ai didi

iOS:每 x 秒更新一次类方法?

转载 作者:行者123 更新时间:2023-11-28 22:15:08 25 4
gpt4 key购买 nike

我在 iOS 编程和 Objective-C 方面完全是自学的,所以请原谅我在整体行话方面缺乏知识。

我有一个 ACViewController 类及其各自的 .h 和 .m 文件。

此外,我还有名为 ACPortrait_Orient.hACPortrait_Orient.m 的文件,我的 ACPortrait_Orient.m 包含类方法 +(void)updateTimeLabel:(ACViewController *)mainView 以及使我的标签显示当前时间的代码(它也在 ACPortrait_Orient.h 中声明)。

在我的 ACViewController.m 中,我有 [ACPortrait_Orient updateTimeLabel:self]; 包含 #import ACPortrait_Orient.h

我尝试在 +(void)updateTimeLabel:(ACViewController *)mainView 方法,但是我得到以下信息:

2014-02-20 01:04:09.212 AlarmClock[5013:70b] +[ACPortrait_Orient setTimeLabelPortrait:]: unrecognized selector sent to class 0x100073e98
2014-02-20 01:04:11.218 AlarmClock[5013:70b] * Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '+[ACPortrait_Orient setTimeLabelPortrait:]: unrecognized selector sent to class 0x100073e98'

我希望时间标签每秒更新一次,但这种方法似乎行不通。反正我每秒都运行那个类方法吗?

最佳答案

而不是这样调用

[self performSelector:@selector(updateTimeLabel:) withObject:self afterDelay:1.0];

这样调用

[ACPortrait_Orient performSelector:@selector(updateTimeLabel:) withObject:self afterDelay:1.0];

关于iOS:每 x 秒更新一次类方法?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21899606/

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