Skip to content

Instantly share code, notes, and snippets.

@xuyunan
Created January 10, 2013 08:34
Show Gist options
  • Save xuyunan/4500489 to your computer and use it in GitHub Desktop.
Save xuyunan/4500489 to your computer and use it in GitHub Desktop.
随机数
// 产生随机数种子
srandom((unsigned)time(NULL));
- (CGPoint)randomPoint
{
CGPoint result;
NSRect r = [self bounds];
result.x = r.origin.x + random()%(int)r.size.width;
result.y = r.origin.y + random()%(int)r.size.height;
return result;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment