Coding, How-To

iOS: Getting Screen Size

To obtain the screen size based on the orientation and type of device, use this: screenWidth will return the width, and screenHeight, the height of your screen, even when your device is in the landscape orientation.









Coding

iOS: Random Number Generation

Use the arc4random function to generate random numbers in a range. Suppose you have to generate a random number from 0 to 99. Do: int randomNum0to99 = arc4random() % 100; Or: int randomNum0to99 = arc4random_uniform(100); Between the 2 codes, the latter is preferred because: arc4random_uniform() will return a uniformly distributed random number less than upper_bound.… Read More iOS: Random Number Generation