2
From the iOS docs:부정적인 NSTimeInterval :
seconds
The number of seconds from the current date and time for the new date. Use a negative value to specify a date before the current date.
그러나이 코드는 2148에서 날짜를 제공합니다 : 그것은해야
#import <Foundation/Foundation.h>
#import <stdlib.h>
int main(int argc, const char * argv[])
{
@autoreleasepool {
for(int i = 0; i < 30; i++) {
NSDate* date = [NSDate dateWithTimeIntervalSinceNow:(NSTimeInterval)-((u_int32_t)i * 12 * 60 * 60 + arc4random_uniform(8 * 60 * 60))];
NSLog(@"%@", date);
}
}
return 0;
}
는 가까운 과거의 반 임의의 날짜와 시간을 생성합니다.
부호 없음 INT의 부정적인는 양수이다. –
@HotLicks 부정적인 문제가 발생하기 전에 NSTimeInterval에 전송 해 주셔서 감사합니다. – Tyilo