我一直在为寻找快速解决方案而绞尽脑汁。
我需要根据特定时区的当前时间在特定时间触发 NSTime。
例如,我得到 PST 中的当前时间:
NSDate *now = [NSDate date];
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
dateFormatter.dateFormat = @"HH:mm:ss";
NSCalendar * cal = [[NSCalendar alloc] initWithCalendarIdentifier: NSGregorianCalendar];
[cal setTimeZone:[NSTimeZone timeZoneWithAbbreviation:@"PST"]];
NSDateComponents * comps = [cal components:NSHourCalendarUnit fromDate:now];
我看到时间是 2 (14) 得到 [comps hour],我需要在当天下午 2:30(14:30)触发计时器。我需要帮助将其转换回来并进行数学运算以说明计时器触发前还有多长时间。我将根据当前时间设置几个不同的计时器。当我在 PST 中查看时间时,我知道计时器和时间设置是在 GMT 中完成的。这又是一个转折……
提前致谢...