// REF:http://developer.apple.com/library/mac/#documentation/Cocoa/Reference/Foundation/Classes/NSDate_Class/Reference/Reference.html NSTimeInterval time = [[NSDate date] timeIntervalSince1970];// REF:http://developer.apple.com/library/mac/#documentation/Cocoa/Reference/Foundation/Miscellaneous/Foundation_DataTypes/Reference/reference.html NSTimeIntervalUsed to specify a time interval, in seconds. typedef double NSTimeInterval; DiscussionNSTimeInterval is always specified in seconds; it yields sub-millisecond precision over a range of 10,000 years.得到两个NSTimeInterval的秒数后减一下就知道了。
[NSTimer scheduledTimerWithTimeInterval:2.0 target:self selector:@selector(你的方法名) userInfo:nil repeats:NO];
如果是监听动作发生后的时间就需要新建一个线程了
在每个动作(我觉得你的意思应该是每个动作绑定在一个方法里)里都做一个flag标记,标记默认为NO,如果其他动作执行,就将flag置为YES,
应该类似
- (void)其他任何动作的方法 {
flag = YES;
//其他方法
}
然后在onTime这么写
- (void)onTime
{
if(!flag) {
另外一个动作
}
}
NSTimeInterval time = [[NSDate date] timeIntervalSince1970];// REF:http://developer.apple.com/library/mac/#documentation/Cocoa/Reference/Foundation/Miscellaneous/Foundation_DataTypes/Reference/reference.html
NSTimeIntervalUsed to specify a time interval, in seconds.
typedef double NSTimeInterval;
DiscussionNSTimeInterval is always specified in seconds; it yields sub-millisecond precision over a range of 10,000 years.得到两个NSTimeInterval的秒数后减一下就知道了。