问题描述
- ios如何设定时常并判断操作是否超时
-
我的写法是NSDate *timeout = [[NSDate alloc]initWithTimeIntervalSinceNow:30]; dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ while ([timeout timeIntervalSinceNow] > 0) { NSLog(@"%f",[timeout timeIntervalSinceNow]); //do check stuff sleep(1); } });
时间: 2024-11-01 15:12:38