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
Xcode6 GameCenter 実装

Xcode6(iOS7以上)でのGameCenter実装 検索であまり見つからな …

no image
BGM・SE 導入方法

音楽:導入方法 1… AVFoundationフレームワークを追加 2… hファ …

no image
NSArray valueForkeypath関数

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

no image
CheatSheet

Xcodeの便利なショートカットキー 良く使ってるなと感じたら追記 Cmd+Al …

no image
UIViewを透明にする

// opaque属性にNOを設定する事で、背景透過を許可する。 UIView …

eyechatch_xcode_tips-300x300
負の数を絶対数へ変換 abs

負の数を自然数(マイナスを含まない数字)にしたくて、「Xcode 自然数 変換」 …

no image
NSLog まとめ

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

eyechatch_xcode_tips-300x300
transform中の座標取得

CGAffineTransformを使用して画像を変化させている最中の座標取得方 …

no image
UILabelをコードで生成(Tips付)

Main Storyboard (IB)に用意されている Label を使わずに …

no image
ステータスバーを隠す方法

Deployment Info の Status Bar Style 下部にある …