在 OC 中可以这样写
NSTimeInterval timeInterval = [self timeIntervalSinceNow];
timeInterval = -timeInterval;
timeInterval = timeInterval - 8 * 60 * 60;
long temp = 0;
NSString *result;
if (timeInterval < 60) {
result = [NSString stringWithFormat:@"just"];
} else if ((temp = (long) (timeInterval / 60)) < 60) {
result = [NSString stringWithFormat:@"%ld m", temp];
} else if ((temp = temp / 60) < 24) {
result = [NSString stringWithFormat:@"%ld h", temp];
}
就是在 if 的时候可以对 temp 同时进行赋值与比较,那么 swift3 可以这样写吗,试了一会总是报红。