Views 68041 Votes 0 Comment 0
?

Shortcut

PrevPrev Article

NextNext Article

Larger Font Smaller Font Up Down Go comment Print
?

Shortcut

PrevPrev Article

NextNext Article

Larger Font Smaller Font Up Down Go comment Print
랜덤함수 사용시..

iOS
There are several built-in randomizers on the iPhone, and most people's first thought is to use rand() after seeding it by calling

srandom(time(NULL));

But... rand() is really not a very good PRNG. random() is a little better, but still less then ideal. Fortunately, these are not the only ones available on the iPhone. Personally, I like arc4random() because it's a decent pseudo-random algorithm and has twice the range or rand().

On the iPhone, RAND_MAX is 0x7fffffff (2147483647), while arc4random() will return a maximum value of 0x100000000 (4294967296), giving much more precision. You also don't need to seed arc4random(), as the first call to it automatically seeds it. 

결론은 arc4random() 을 사용하자.

[출처] http://iphonedevelopment.blogspot.com/2008/10/random-thoughts-rand-vs-arc4random.html

?

  1. 무료로 HTTPS 적용하기 (Lets' Encrypt)

  2. 모바일 프로그래머가 갖추어야 할 필수 역량

  3. [ios] Facebook Cache 갱신하는 함수

  4. [js] Javascript로 만든 포트리스 (2010)

  5. 종합시험 관련 자료

  6. [ios] 동영상 플레이어 샘플 (for PIP Player)

  7. Mac OS 에 Jenkins 설치하기 (Homebrew)

  8. 사이버보안실무 수업 메모

  9. [ios] Xcode에서 특정 파일만 ARC 따로 설정하는 방법

  10. [mysql] 쿼리 실행시 ERROR 1366 (HY000) : incorrect string value : for column

  11. 사이버보안실무 수업 메모

  12. [ios] 비디오,네트워크,소셜로그인 테스트

  13. [ios] NSString, RegularExpression Find/Replace

  14. [ios] Facebook SDK 로그인 설명

  15. 사이버보안실무 시험.

  16. [ios] 코코아 프로그래밍의 네이밍 룰(명명 규칙)

Board Pagination Prev 1 ... 65 66 67 68 69 ... 74 Next
/ 74