Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // a random class made to make arc4random() easier to work with
- // Random.h
- @interface Random : NSObject //class "Random" inherits from NSObject (good practice)
- +(NSInteger) getValueBetween: (NSInteger)valA and: (NSInteger)valB; // + means static method
- @end
- // Random.m
- @implementation Random
- +(NSInteger) getValueBetween: (NSInteger)valA and: (NSInteger)valB {
- if(valA < valB) // if valA is smaller do the following, else swap the values
- return valA + arc4random() % (valA - valB +1);
- else
- return valB + arc4random() % (valB - valA +1);
- }
- @end
Advertisement
Add Comment
Please, Sign In to add comment