乱数のこと
2014/11/02
乱数(ランダムな数)を取り出す際 rand や arc4random を使用しますが、何度も使うと取り出す数に偏りが出てきてしまいます。
randの例:
int randInt = rand() % 100;
arc4randomの例:
int randInt = arc4random() %100;
arc4random_uniformを使用することで偏りを軽減することができます。
以下 arc4random_uniform の参考
int randInt = arc4random_uniform(100);
関連記事
-
-
iPhone画面サイズ
3.5inch 320 x 480px (Retina 640 x 960px) …
-
-
ボタンに画像(背景)を指定する
// ボタンのサイズを指定する UIButton *startBtn = [[U …
-
-
UIImageView 画像の差し替え
[UIImageView alloc] 後の画像を変換する時は下記コードを参照し …
-
-
UIButton 同時押し制御
UIButton *myBtn = [UIButton alloc] init] …
-
-
transform中の座標取得
CGAffineTransformを使用して画像を変化させている最中の座標取得方 …
-
-
UIImageViewにボタンを貼りたい場合
タイトル画面などを作りたい場合、UIImageViewを使用して背景などを作るこ …
-
-
.selected
インスタンス名.selected で BOOLを宣言せずにボタンのON/OFF状 …
-
-
SNS連携
Twitter・Facebookとの連携は #import <Social …
-
-
Xcode6 GameCenter 実装
Xcode6(iOS7以上)でのGameCenter実装 検索であまり見つからな …
-
-
タッチイベント:有効・無効
// タッチイベントを有効にしたい場合の処理 [[UIApplication s …
- PREV
- Sublime Text 3
- NEXT
- CheatSheet