Tabs

iPhone&Androidのアプリ制作・デザイン

*

乱数のこと

      2014/11/02


乱数(ランダムな数)を取り出す際 rand や arc4random を使用しますが、何度も使うと取り出す数に偏りが出てきてしまいます。

randの例:
int randInt = rand() % 100;

arc4randomの例:
int randInt = arc4random() %100;

arc4random_uniformを使用することで偏りを軽減することができます。
以下 arc4random_uniform の参考

int randInt = arc4random_uniform(100);


 - Begin

  関連記事

eyechatch_xcode_tips-300x300
ボタンに画像(背景)を指定する

// ボタンのサイズを指定する UIButton *startBtn = [[U …

eyechatch_xcode_tips-300x300
LaunchImage 関連の設定

▼アプリ起動時のスプラッシュ画面 通常はチラっと一瞬だけ表示されるスプラッシュ画 …

no image
UIImageViewにボタンを貼りたい場合

タイトル画面などを作りたい場合、UIImageViewを使用して背景などを作るこ …

eyechatch_xcode_tips-300x300
UIButton 同時押し制御

UIButton *myBtn = [UIButton alloc] init] …

eyechatch_xcode_tips-300x300
経過時間を算出する

まず比較する為の時刻を予めローカルに保存するために NSUserDefaults …

eyechatch_xcode_tips-300x300
テキストの文字間を詰める

UILabelなどで文字間を詰める(カーニング)したい時がちょいちょいあると思い …

no image
NSArray valueForkeypath関数

NSArrayやNSDictionaryを多用する人にお勧めですCoreData …

no image
iPhone画面サイズ

3.5inch 320 x 480px (Retina 640 x 960px) …

no image
NSLog まとめ

デバッグする時などに、ログを出力する方法としてNSLogを使用します。 文字列を …

no image
アプリの名前をつける

iPhoneのホーム画面に表示される「アプリ名」の付け方 アプリ名の変更には上 …