有个项目要给客户发送随机验证码, 试了下这样可以
1 srand(time(0)); 2 code = [NSString stringWithFormat:@"%d", (rand() % (9999 - 1001)) + 1001];