【问题标题】:iphone development: how to call a function [duplicate]iphone开发:如何调用函数[重复]
【发布时间】:2012-08-18 17:25:45
【问题描述】:

假设我有一个 void 函数,它的主体中只有 NSLog(@"Call me");

在我看来,我怎么能像每十秒钟一样调用它。我知道这听起来像是非常初学者的问题,但我真的需要它

【问题讨论】:

标签: iphone objective-c function methods method-call


【解决方案1】:

使用 NSTimer 类 [NSTimer scheduleTimerWithTimeInterval:10.0 target:self 选择器:@selector(makeMyProgressBarMoving) userInfo:nil repeats:YES]

【讨论】:

    【解决方案2】:
    NSTimer *timer = [NSTimer scheduledTimerWithTimeInterval:10 target:self selector:@selector(yourMethod) userInfo:nil repeats:YES];
    

    【讨论】:

    • 没关系,但我希望它在 5 次迭代后停止它。然而它会走向无穷大。
    猜你喜欢
    • 2012-08-18
    • 1970-01-01
    • 1970-01-01
    • 2011-01-16
    • 2014-07-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-05-30
    相关资源
    最近更新 更多